@@ -51,30 +51,29 @@ impl ByteString {
51
51
Self ( src)
52
52
}
53
53
54
- /// Returns a slice of self that is equivalent to the given `subset`. Corresponds to [`Bytes::slice_ref`] .
54
+ /// Returns a byte string that is equivalent to the given `subset`.
55
55
///
56
- /// When processing a `ByteString` buffer with other tools, one often gets a
57
- /// `&str` which is in fact a slice of the `ByteString`, i.e. a subset of it.
58
- /// This function turns that `&str` into another `ByteString`, as if one had
59
- /// sliced the `ByteString` with the offsets that correspond to `subset`.
56
+ /// When processing a `ByteString` buffer with other tools, one often gets a `&str` which is in
57
+ /// fact a slice of the `ByteString`; i.e., a subset of it. This function turns that `&str` into
58
+ /// another `ByteString`, as if one had sliced the `ByteString` with the offsets that correspond
59
+ /// to `subset`.
60
+ ///
61
+ /// Corresponds to [`Bytes::slice_ref`].
60
62
///
61
63
/// This operation is `O(1)`.
62
64
///
63
- /// # Examples
65
+ /// # Panics
66
+ /// Requires that the given `subset` str is in fact contained within the `ByteString` buffer;
67
+ /// otherwise this function will panic.
64
68
///
69
+ /// # Examples
65
70
/// ```
66
- /// use bytestring::ByteString;
67
- ///
71
+ /// # use bytestring::ByteString;
68
72
/// let string = ByteString::from_static(" foo ");
69
73
/// let subset = string.trim();
70
74
/// let substring = string.slice_ref(subset);
71
75
/// assert_eq!(substring, "foo");
72
76
/// ```
73
- ///
74
- /// # Panics
75
- ///
76
- /// Requires that the given `subset` str is in fact contained within the
77
- /// `ByteString` buffer; otherwise this function will panic.
78
77
pub fn slice_ref ( & self , subset : & str ) -> Self {
79
78
Self ( self . 0 . slice_ref ( subset. as_bytes ( ) ) )
80
79
}
0 commit comments