@@ -231,7 +231,7 @@ impl Default for ByteString {
231
231
232
232
#[ unstable( feature = "bstr" , issue = "134915" ) ]
233
233
impl From < ByteString > for Vec < u8 > {
234
- /// Return the inner `Vec` of the byte string
234
+ /// Return the inner `Vec` of the byte string.
235
235
#[ inline]
236
236
fn from ( s : ByteString ) -> Self {
237
237
s. 0
@@ -265,6 +265,10 @@ impl From<ByteString> for Vec<u8> {
265
265
#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
266
266
#[ unstable( feature = "bstr" , issue = "134915" ) ]
267
267
impl < ' a > From < & ' a ByteStr > for ByteString {
268
+ /// Convert the `ByteStr` to a `Vec` then wrap it in a `ByteString`.
269
+ ///
270
+ /// ## Cost
271
+ /// Allocates a new `Vec`
268
272
#[ inline]
269
273
fn from ( s : & ' a ByteStr ) -> Self {
270
274
ByteString ( s. 0 . to_vec ( ) )
@@ -274,6 +278,7 @@ impl<'a> From<&'a ByteStr> for ByteString {
274
278
#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
275
279
#[ unstable( feature = "bstr" , issue = "134915" ) ]
276
280
impl < ' a > From < ByteString > for Cow < ' a , ByteStr > {
281
+ /// Wrap `ByteString` in `Cow::Owned`.
277
282
#[ inline]
278
283
fn from ( s : ByteString ) -> Self {
279
284
Cow :: Owned ( s)
@@ -283,6 +288,7 @@ impl<'a> From<ByteString> for Cow<'a, ByteStr> {
283
288
#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
284
289
#[ unstable( feature = "bstr" , issue = "134915" ) ]
285
290
impl < ' a > From < & ' a ByteString > for Cow < ' a , ByteStr > {
291
+ /// Wrap `ByteString` as byte str in `Cow::Borrowed`.
286
292
#[ inline]
287
293
fn from ( s : & ' a ByteString ) -> Self {
288
294
Cow :: Borrowed ( s. as_bytestr ( ) )
@@ -636,7 +642,7 @@ impl Clone for Box<ByteStr> {
636
642
#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
637
643
#[ unstable( feature = "bstr" , issue = "134915" ) ]
638
644
impl < ' a > From < & ' a ByteStr > for Cow < ' a , ByteStr > {
639
- /// Create a `Borrowed` cow from a `ByteStr`
645
+ /// Create a `Borrowed` cow from a `ByteStr`.
640
646
#[ inline]
641
647
fn from ( s : & ' a ByteStr ) -> Self {
642
648
Cow :: Borrowed ( s)
@@ -646,7 +652,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
646
652
#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
647
653
#[ unstable( feature = "bstr" , issue = "134915" ) ]
648
654
impl From < Box < [ u8 ] > > for Box < ByteStr > {
649
- /// Create a `Box<[u8]>` from `Box<ByteStr>`s raw
655
+ /// Create a `Box<[u8]>` from `Box<ByteStr>`s raw.
650
656
#[ inline]
651
657
fn from ( s : Box < [ u8 ] > ) -> Box < ByteStr > {
652
658
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -657,7 +663,7 @@ impl From<Box<[u8]>> for Box<ByteStr> {
657
663
#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
658
664
#[ unstable( feature = "bstr" , issue = "134915" ) ]
659
665
impl From < Box < ByteStr > > for Box < [ u8 ] > {
660
- /// Create a `Box<ByteStr>` from `Box<[u8]>`s raw
666
+ /// Create a `Box<ByteStr>` from `Box<[u8]>`s raw.
661
667
#[ inline]
662
668
fn from ( s : Box < ByteStr > ) -> Box < [ u8 ] > {
663
669
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -668,7 +674,7 @@ impl From<Box<ByteStr>> for Box<[u8]> {
668
674
#[ unstable( feature = "bstr" , issue = "134915" ) ]
669
675
#[ cfg( not( no_rc) ) ]
670
676
impl From < Rc < [ u8 ] > > for Rc < ByteStr > {
671
- /// Create a `Rc<[u8]>` from `Rc<ByteStr>`s raw
677
+ /// Create a `Rc<[u8]>` from `Rc<ByteStr>`s raw.
672
678
#[ inline]
673
679
fn from ( s : Rc < [ u8 ] > ) -> Rc < ByteStr > {
674
680
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -679,7 +685,7 @@ impl From<Rc<[u8]>> for Rc<ByteStr> {
679
685
#[ unstable( feature = "bstr" , issue = "134915" ) ]
680
686
#[ cfg( not( no_rc) ) ]
681
687
impl From < Rc < ByteStr > > for Rc < [ u8 ] > {
682
- /// Create a `Rc<ByteStr>` from `Rc<[u8]>`s raw
688
+ /// Create a `Rc<ByteStr>` from `Rc<[u8]>`s raw.
683
689
#[ inline]
684
690
fn from ( s : Rc < ByteStr > ) -> Rc < [ u8 ] > {
685
691
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -690,7 +696,7 @@ impl From<Rc<ByteStr>> for Rc<[u8]> {
690
696
#[ unstable( feature = "bstr" , issue = "134915" ) ]
691
697
#[ cfg( all( not( no_rc) , not( no_sync) , target_has_atomic = "ptr" ) ) ]
692
698
impl From < Arc < [ u8 ] > > for Arc < ByteStr > {
693
- /// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw
699
+ /// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw.
694
700
#[ inline]
695
701
fn from ( s : Arc < [ u8 ] > ) -> Arc < ByteStr > {
696
702
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -701,7 +707,7 @@ impl From<Arc<[u8]>> for Arc<ByteStr> {
701
707
#[ unstable( feature = "bstr" , issue = "134915" ) ]
702
708
#[ cfg( all( not( no_rc) , not( no_sync) , target_has_atomic = "ptr" ) ) ]
703
709
impl From < Arc < ByteStr > > for Arc < [ u8 ] > {
704
- /// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw
710
+ /// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw.
705
711
#[ inline]
706
712
fn from ( s : Arc < ByteStr > ) -> Arc < [ u8 ] > {
707
713
// SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -722,7 +728,7 @@ impl<'a> TryFrom<&'a ByteStr> for String {
722
728
type Error = core:: str:: Utf8Error ;
723
729
724
730
/// Convert `ByteStr`s bytes to a utf-8 `String`.
725
- ///
731
+ ///
726
732
/// # Errors
727
733
/// If `ByteStr` is not valid utf-8
728
734
#[ inline]
0 commit comments