Skip to content

Commit

Permalink
change Bytes::is_unique to take &self
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyborus04 committed Jan 9, 2024
1 parent b37e569 commit e8365ad
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bytes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,21 @@ impl Bytes {
///
/// Always returns false if the data is backed by a static slice.
///
/// The result of this method may be invalidated immediately if another
/// thread clones this value while this is being called. Ensure you have
/// unique access to this value (`&mut Bytes`) first if you need to be
/// certain the result is valid (i.e. for safety reasons)
/// # Examples
///
/// ```
/// use bytes::Bytes;
///
/// let mut a = Bytes::from(vec![1, 2, 3]);
/// let a = Bytes::from(vec![1, 2, 3]);
/// assert!(a.is_unique());
/// let b = a.clone();
/// assert!(!a.is_unique());
/// ```
pub fn is_unique(&mut self) -> bool {
pub fn is_unique(&self) -> bool {
unsafe { (self.vtable.is_unique)(&self.data) }
}

Expand Down

0 comments on commit e8365ad

Please sign in to comment.