Skip to content

Commit 6061a44

Browse files
committed
slice_ref doc tweaks
1 parent 363984a commit 6061a44

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

bytestring/src/lib.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,30 +51,29 @@ impl ByteString {
5151
Self(src)
5252
}
5353

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`.
5555
///
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`].
6062
///
6163
/// This operation is `O(1)`.
6264
///
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.
6468
///
69+
/// # Examples
6570
/// ```
66-
/// use bytestring::ByteString;
67-
///
71+
/// # use bytestring::ByteString;
6872
/// let string = ByteString::from_static(" foo ");
6973
/// let subset = string.trim();
7074
/// let substring = string.slice_ref(subset);
7175
/// assert_eq!(substring, "foo");
7276
/// ```
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.
7877
pub fn slice_ref(&self, subset: &str) -> Self {
7978
Self(self.0.slice_ref(subset.as_bytes()))
8079
}

0 commit comments

Comments
 (0)