Expand description
A Cow<'a, [u8]> wrapper that supports serializing efficiently in Serde.
Tuple Fields
0: Cow<'a, [u8]>Implementations
Methods from Deref<Target = Cow<'a, [u8]>>
🔬 This is a nightly-only experimental API. (cow_is_borrowed)
cow_is_borrowed)Returns true if the data is borrowed, i.e. if to_mut would require additional work.
Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow = Cow::Borrowed("moo");
assert!(cow.is_borrowed());
let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
assert!(!bull.is_borrowed());🔬 This is a nightly-only experimental API. (cow_is_borrowed)
cow_is_borrowed)Returns true if the data is owned, i.e. if to_mut would be a no-op.
Examples
#![feature(cow_is_borrowed)]
use std::borrow::Cow;
let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
assert!(cow.is_owned());
let bull = Cow::Borrowed("...moo?");
assert!(!bull.is_owned());Acquires a mutable reference to the owned form of the data.
Clones the data if it is not already owned.
Examples
use std::borrow::Cow;
let mut cow = Cow::Borrowed("foo");
cow.to_mut().make_ascii_uppercase();
assert_eq!(
cow,
Cow::Owned(String::from("FOO")) as Cow<str>
);Trait Implementations
Deserialize this value from the given Serde deserializer. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <=
operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
Auto Trait Implementations
impl<'a> RefUnwindSafe for CowBytes<'a>
impl<'a> UnwindSafe for CowBytes<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more