@@ -184,6 +184,10 @@ impl Default for ByteString {
184184// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
185185// #[unstable(feature = "bstr", issue = "134915")]
186186// impl<'a, const N: usize> From<&'a [u8; N]> for ByteString {
187+ // /// Make a `ByteString` from a byte array ref.
188+ // ///
189+ // /// ## Cost
190+ // /// Allocates a new `Vec`
187191// #[inline]
188192// fn from(s: &'a [u8; N]) -> Self {
189193// ByteString(s.as_slice().to_vec())
@@ -193,6 +197,10 @@ impl Default for ByteString {
193197// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
194198// #[unstable(feature = "bstr", issue = "134915")]
195199// impl<const N: usize> From<[u8; N]> for ByteString {
200+ // /// Make a `ByteString` from a byte array.
201+ // ///
202+ // /// ## Cost
203+ // /// Allocates a new `Vec`
196204// #[inline]
197205// fn from(s: [u8; N]) -> Self {
198206// ByteString(s.as_slice().to_vec())
@@ -202,6 +210,10 @@ impl Default for ByteString {
202210// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
203211// #[unstable(feature = "bstr", issue = "134915")]
204212// impl<'a> From<&'a [u8]> for ByteString {
213+ // /// Make a `ByteString` from a byte slice.
214+ // ///
215+ // /// ## Cost
216+ // /// Allocates a new `Vec`
205217// #[inline]
206218// fn from(s: &'a [u8]) -> Self {
207219// ByteString(s.to_vec())
@@ -210,6 +222,7 @@ impl Default for ByteString {
210222//
211223// #[unstable(feature = "bstr", issue = "134915")]
212224// impl From<Vec<u8>> for ByteString {
225+ // /// Make a `ByteString` with `Vec<u8>` as inner
213226// #[inline]
214227// fn from(s: Vec<u8>) -> Self {
215228// ByteString(s)
@@ -218,6 +231,7 @@ impl Default for ByteString {
218231
219232#[ unstable( feature = "bstr" , issue = "134915" ) ]
220233impl From < ByteString > for Vec < u8 > {
234+ /// Return the inner `Vec` of the byte string
221235 #[ inline]
222236 fn from ( s : ByteString ) -> Self {
223237 s. 0
@@ -229,6 +243,10 @@ impl From<ByteString> for Vec<u8> {
229243// #[cfg(not(test))] // https://github.com/rust-lang/rust/issues/135100
230244// #[unstable(feature = "bstr", issue = "134915")]
231245// impl<'a> From<&'a str> for ByteString {
246+ // /// Make a `ByteString` from a string slices bytes.
247+ // ///
248+ // /// ## Cost
249+ // /// Allocates a new `Vec`
232250// #[inline]
233251// fn from(s: &'a str) -> Self {
234252// ByteString(s.as_bytes().to_vec())
@@ -237,6 +255,7 @@ impl From<ByteString> for Vec<u8> {
237255//
238256// #[unstable(feature = "bstr", issue = "134915")]
239257// impl From<String> for ByteString {
258+ // /// Create a `ByteString` from a `String`s bytes
240259// #[inline]
241260// fn from(s: String) -> Self {
242261// ByteString(s.into_bytes())
@@ -617,6 +636,7 @@ impl Clone for Box<ByteStr> {
617636#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
618637#[ unstable( feature = "bstr" , issue = "134915" ) ]
619638impl < ' a > From < & ' a ByteStr > for Cow < ' a , ByteStr > {
639+ /// Create a `Borrowed` cow from a `ByteStr`
620640 #[ inline]
621641 fn from ( s : & ' a ByteStr ) -> Self {
622642 Cow :: Borrowed ( s)
@@ -626,6 +646,7 @@ impl<'a> From<&'a ByteStr> for Cow<'a, ByteStr> {
626646#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
627647#[ unstable( feature = "bstr" , issue = "134915" ) ]
628648impl From < Box < [ u8 ] > > for Box < ByteStr > {
649+ /// Create a `Box<[u8]>` from `Box<ByteStr>`s raw
629650 #[ inline]
630651 fn from ( s : Box < [ u8 ] > ) -> Box < ByteStr > {
631652 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -636,6 +657,7 @@ impl From<Box<[u8]>> for Box<ByteStr> {
636657#[ cfg( not( test) ) ] // https://github.com/rust-lang/rust/issues/135100
637658#[ unstable( feature = "bstr" , issue = "134915" ) ]
638659impl From < Box < ByteStr > > for Box < [ u8 ] > {
660+ /// Create a `Box<ByteStr>` from `Box<[u8]>`s raw
639661 #[ inline]
640662 fn from ( s : Box < ByteStr > ) -> Box < [ u8 ] > {
641663 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -646,6 +668,7 @@ impl From<Box<ByteStr>> for Box<[u8]> {
646668#[ unstable( feature = "bstr" , issue = "134915" ) ]
647669#[ cfg( not( no_rc) ) ]
648670impl From < Rc < [ u8 ] > > for Rc < ByteStr > {
671+ /// Create a `Rc<[u8]>` from `Rc<ByteStr>`s raw
649672 #[ inline]
650673 fn from ( s : Rc < [ u8 ] > ) -> Rc < ByteStr > {
651674 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -656,6 +679,7 @@ impl From<Rc<[u8]>> for Rc<ByteStr> {
656679#[ unstable( feature = "bstr" , issue = "134915" ) ]
657680#[ cfg( not( no_rc) ) ]
658681impl From < Rc < ByteStr > > for Rc < [ u8 ] > {
682+ /// Create a `Rc<ByteStr>` from `Rc<[u8]>`s raw
659683 #[ inline]
660684 fn from ( s : Rc < ByteStr > ) -> Rc < [ u8 ] > {
661685 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -666,6 +690,7 @@ impl From<Rc<ByteStr>> for Rc<[u8]> {
666690#[ unstable( feature = "bstr" , issue = "134915" ) ]
667691#[ cfg( all( not( no_rc) , not( no_sync) , target_has_atomic = "ptr" ) ) ]
668692impl From < Arc < [ u8 ] > > for Arc < ByteStr > {
693+ /// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw
669694 #[ inline]
670695 fn from ( s : Arc < [ u8 ] > ) -> Arc < ByteStr > {
671696 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -676,6 +701,7 @@ impl From<Arc<[u8]>> for Arc<ByteStr> {
676701#[ unstable( feature = "bstr" , issue = "134915" ) ]
677702#[ cfg( all( not( no_rc) , not( no_sync) , target_has_atomic = "ptr" ) ) ]
678703impl From < Arc < ByteStr > > for Arc < [ u8 ] > {
704+ /// Create a `Arc<ByteStr>` from `Arc<[u8]>`s raw
679705 #[ inline]
680706 fn from ( s : Arc < ByteStr > ) -> Arc < [ u8 ] > {
681707 // SAFETY: `ByteStr` is a transparent wrapper around `[u8]`.
@@ -695,6 +721,10 @@ impl_partial_eq_ord_cow!(&'a ByteStr, Cow<'a, [u8]>);
695721impl < ' a > TryFrom < & ' a ByteStr > for String {
696722 type Error = core:: str:: Utf8Error ;
697723
724+ /// Convert `ByteStr`s bytes to a utf-8 `String`.
725+ ///
726+ /// # Errors
727+ /// If `ByteStr` is not valid utf-8
698728 #[ inline]
699729 fn try_from ( s : & ' a ByteStr ) -> Result < Self , Self :: Error > {
700730 Ok ( core:: str:: from_utf8 ( & s. 0 ) ?. into ( ) )
0 commit comments