Skip to content

Commit e8365ad

Browse files
committed
change Bytes::is_unique to take &self
1 parent b37e569 commit e8365ad

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/bytes.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,21 @@ impl Bytes {
214214
///
215215
/// Always returns false if the data is backed by a static slice.
216216
///
217+
/// The result of this method may be invalidated immediately if another
218+
/// thread clones this value while this is being called. Ensure you have
219+
/// unique access to this value (`&mut Bytes`) first if you need to be
220+
/// certain the result is valid (i.e. for safety reasons)
217221
/// # Examples
218222
///
219223
/// ```
220224
/// use bytes::Bytes;
221225
///
222-
/// let mut a = Bytes::from(vec![1, 2, 3]);
226+
/// let a = Bytes::from(vec![1, 2, 3]);
223227
/// assert!(a.is_unique());
224228
/// let b = a.clone();
225229
/// assert!(!a.is_unique());
226230
/// ```
227-
pub fn is_unique(&mut self) -> bool {
231+
pub fn is_unique(&self) -> bool {
228232
unsafe { (self.vtable.is_unique)(&self.data) }
229233
}
230234

0 commit comments

Comments
 (0)