pub enum Cow<'a, B>{
Borrowed(&'a B),
Owned(<B as ToOwned>::Owned),
}
alloc
only.Expand description
A clone-on-write smart pointer.
The type Cow
is a smart pointer providing clone-on-write functionality: it
can enclose and provide immutable access to borrowed data, and clone the
data lazily when mutation or ownership is required. The type is designed to
work with general borrowed data via the Borrow
trait.
Cow
implements Deref
, which means that you can call
non-mutating methods directly on the data it encloses. If mutation
is desired, to_mut
will obtain a mutable reference to an owned
value, cloning if necessary.
If you need reference-counting pointers, note that
Rc::make_mut
and
Arc::make_mut
can provide clone-on-write
functionality as well.
§Examples
use std::borrow::Cow;
fn abs_all(input: &mut Cow<'_, [i32]>) {
for i in 0..input.len() {
let v = input[i];
if v < 0 {
// Clones into a vector if not already owned.
input.to_mut()[i] = -v;
}
}
}
// No clone occurs because `input` doesn't need to be mutated.
let slice = [0, 1, 2];
let mut input = Cow::from(&slice[..]);
abs_all(&mut input);
// Clone occurs because `input` needs to be mutated.
let slice = [-1, 0, 1];
let mut input = Cow::from(&slice[..]);
abs_all(&mut input);
// No clone occurs because `input` is already owned.
let mut input = Cow::from(vec![-1, 0, 1]);
abs_all(&mut input);
Another example showing how to keep Cow
in a struct:
use std::borrow::Cow;
struct Items<'a, X> where [X]: ToOwned<Owned = Vec<X>> {
values: Cow<'a, [X]>,
}
impl<'a, X: Clone + 'a> Items<'a, X> where [X]: ToOwned<Owned = Vec<X>> {
fn new(v: Cow<'a, [X]>) -> Self {
Items { values: v }
}
}
// Creates a container from borrowed values of a slice
let readonly = [1, 2];
let borrowed = Items::new((&readonly[..]).into());
match borrowed {
Items { values: Cow::Borrowed(b) } => println!("borrowed {b:?}"),
_ => panic!("expect borrowed value"),
}
let mut clone_on_write = borrowed;
// Mutates the data from slice into owned vec and pushes a new value on top
clone_on_write.values.to_mut().push(3);
println!("clone_on_write = {:?}", clone_on_write.values);
// The data was mutated. Let's check it out.
match clone_on_write {
Items { values: Cow::Owned(_) } => println!("clone_on_write contains owned data"),
_ => panic!("expect owned data"),
}
Variants§
Implementations§
Source§impl<B> Cow<'_, B>
impl<B> Cow<'_, B>
Sourcepub const fn is_borrowed(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed
)
pub const fn is_borrowed(&self) -> bool
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());
Sourcepub const fn is_owned(&self) -> bool
🔬This is a nightly-only experimental API. (cow_is_borrowed
)
pub const fn is_owned(&self) -> bool
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());
1.0.0 · Sourcepub fn to_mut(&mut self) -> &mut <B as ToOwned>::Owned
pub fn to_mut(&mut self) -> &mut <B as ToOwned>::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>
);
1.0.0 · Sourcepub fn into_owned(self) -> <B as ToOwned>::Owned
pub fn into_owned(self) -> <B as ToOwned>::Owned
Extracts the owned data.
Clones the data if it is not already owned.
§Examples
Calling into_owned
on a Cow::Borrowed
returns a clone of the borrowed data:
use std::borrow::Cow;
let s = "Hello world!";
let cow = Cow::Borrowed(s);
assert_eq!(
cow.into_owned(),
String::from(s)
);
Calling into_owned
on a Cow::Owned
returns the owned data. The data is moved out of the
Cow
without being cloned.
use std::borrow::Cow;
let s = "Hello world!";
let cow: Cow<'_, str> = Cow::Owned(String::from(s));
assert_eq!(
cow.into_owned(),
String::from(s)
);
Trait Implementations§
1.14.0 · Source§impl<'a> AddAssign<&'a str> for Cow<'a, str>
impl<'a> AddAssign<&'a str> for Cow<'a, str>
Source§fn add_assign(&mut self, rhs: &'a str)
fn add_assign(&mut self, rhs: &'a str)
+=
operation. Read more§impl<'a, T> ArchiveWith<Cow<'a, [T]>> for AsOwned
impl<'a, T> ArchiveWith<Cow<'a, [T]>> for AsOwned
§type Archived = ArchivedVec<<T as Archive>::Archived>
type Archived = ArchivedVec<<T as Archive>::Archived>
Self
with F
.§type Resolver = VecResolver
type Resolver = VecResolver
Self
with F
.§fn resolve_with(
field: &Cow<'a, [T]>,
resolver: <AsOwned as ArchiveWith<Cow<'a, [T]>>>::Resolver,
out: Place<<AsOwned as ArchiveWith<Cow<'a, [T]>>>::Archived>,
)
fn resolve_with( field: &Cow<'a, [T]>, resolver: <AsOwned as ArchiveWith<Cow<'a, [T]>>>::Resolver, out: Place<<AsOwned as ArchiveWith<Cow<'a, [T]>>>::Archived>, )
F
.§impl<'a> ArchiveWith<Cow<'a, CStr>> for AsOwned
impl<'a> ArchiveWith<Cow<'a, CStr>> for AsOwned
§type Archived = ArchivedCString
type Archived = ArchivedCString
Self
with F
.§type Resolver = CStringResolver
type Resolver = CStringResolver
Self
with F
.§fn resolve_with(
field: &Cow<'a, CStr>,
resolver: <AsOwned as ArchiveWith<Cow<'a, CStr>>>::Resolver,
out: Place<<AsOwned as ArchiveWith<Cow<'a, CStr>>>::Archived>,
)
fn resolve_with( field: &Cow<'a, CStr>, resolver: <AsOwned as ArchiveWith<Cow<'a, CStr>>>::Resolver, out: Place<<AsOwned as ArchiveWith<Cow<'a, CStr>>>::Archived>, )
F
.§impl<'a, F> ArchiveWith<Cow<'a, F>> for AsOwned
impl<'a, F> ArchiveWith<Cow<'a, F>> for AsOwned
§fn resolve_with(
field: &Cow<'a, F>,
resolver: <AsOwned as ArchiveWith<Cow<'a, F>>>::Resolver,
out: Place<<AsOwned as ArchiveWith<Cow<'a, F>>>::Archived>,
)
fn resolve_with( field: &Cow<'a, F>, resolver: <AsOwned as ArchiveWith<Cow<'a, F>>>::Resolver, out: Place<<AsOwned as ArchiveWith<Cow<'a, F>>>::Archived>, )
F
.§impl<'a> ArchiveWith<Cow<'a, str>> for AsOwned
impl<'a> ArchiveWith<Cow<'a, str>> for AsOwned
§type Archived = ArchivedString
type Archived = ArchivedString
Self
with F
.§type Resolver = StringResolver
type Resolver = StringResolver
Self
with F
.§fn resolve_with(
field: &Cow<'a, str>,
resolver: <AsOwned as ArchiveWith<Cow<'a, str>>>::Resolver,
out: Place<<AsOwned as ArchiveWith<Cow<'a, str>>>::Archived>,
)
fn resolve_with( field: &Cow<'a, str>, resolver: <AsOwned as ArchiveWith<Cow<'a, str>>>::Resolver, out: Place<<AsOwned as ArchiveWith<Cow<'a, str>>>::Archived>, )
F
.§impl<'a> Arg for Cow<'a, CStr>
impl<'a> Arg for Cow<'a, CStr>
§fn to_string_lossy(&self) -> Cow<'_, str>
fn to_string_lossy(&self) -> Cow<'_, str>
Cow<'_, str>
.§fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno> ⓘ
fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno> ⓘ
CStr
.§impl<'a> Arg for Cow<'a, OsStr>
impl<'a> Arg for Cow<'a, OsStr>
§fn to_string_lossy(&self) -> Cow<'_, str>
fn to_string_lossy(&self) -> Cow<'_, str>
Cow<'_, str>
.§fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno> ⓘ
fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno> ⓘ
CStr
.§impl<'a> Arg for Cow<'a, str>
impl<'a> Arg for Cow<'a, str>
§fn to_string_lossy(&self) -> Cow<'_, str>
fn to_string_lossy(&self) -> Cow<'_, str>
Cow<'_, str>
.§fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno> ⓘ
fn as_cow_c_str(&self) -> Result<Cow<'_, CStr>, Errno> ⓘ
CStr
.Source§impl<'de, 'a, T> Deserialize<'de> for Cow<'a, T>
impl<'de, 'a, T> Deserialize<'de> for Cow<'a, T>
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Cow<'a, T>, <D as Deserializer<'de>>::Error> ⓘwhere
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Cow<'a, T>, <D as Deserializer<'de>>::Error> ⓘwhere
D: Deserializer<'de>,
§impl<'a, D> DeserializeWith<ArchivedCString, Cow<'a, CStr>, D> for AsOwned
impl<'a, D> DeserializeWith<ArchivedCString, Cow<'a, CStr>, D> for AsOwned
§fn deserialize_with(
field: &ArchivedCString,
deserializer: &mut D,
) -> Result<Cow<'a, CStr>, <D as Fallible>::Error> ⓘ
fn deserialize_with( field: &ArchivedCString, deserializer: &mut D, ) -> Result<Cow<'a, CStr>, <D as Fallible>::Error> ⓘ
F
using the given deserializer.§impl<'a, D> DeserializeWith<ArchivedString, Cow<'a, str>, D> for AsOwned
impl<'a, D> DeserializeWith<ArchivedString, Cow<'a, str>, D> for AsOwned
§fn deserialize_with(
field: &ArchivedString,
deserializer: &mut D,
) -> Result<Cow<'a, str>, <D as Fallible>::Error> ⓘ
fn deserialize_with( field: &ArchivedString, deserializer: &mut D, ) -> Result<Cow<'a, str>, <D as Fallible>::Error> ⓘ
F
using the given deserializer.§impl<'a, T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, Cow<'a, [T]>, D> for AsOwned
impl<'a, T, D> DeserializeWith<ArchivedVec<<T as Archive>::Archived>, Cow<'a, [T]>, D> for AsOwned
1.52.0 · Source§impl<'a> Extend<Cow<'a, OsStr>> for OsString
impl<'a> Extend<Cow<'a, OsStr>> for OsString
Source§fn extend<T>(&mut self, iter: T)
fn extend<T>(&mut self, iter: T)
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)1.19.0 · Source§impl<'a> Extend<Cow<'a, str>> for String
impl<'a> Extend<Cow<'a, str>> for String
Source§fn extend<I>(&mut self, iter: I)
fn extend<I>(&mut self, iter: I)
Source§fn extend_one(&mut self, s: Cow<'a, str>)
fn extend_one(&mut self, s: Cow<'a, str>)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)§impl<'a, 'bump> Extend<Cow<'a, str>> for String<'bump>
impl<'a, 'bump> Extend<Cow<'a, str>> for String<'bump>
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)1.45.0 · Source§impl From<Cow<'_, str>> for Box<str>
impl From<Cow<'_, str>> for Box<str>
Source§fn from(cow: Cow<'_, str>) -> Box<str>
fn from(cow: Cow<'_, str>) -> Box<str>
Converts a Cow<'_, str>
into a Box<str>
When cow
is the Cow::Borrowed
variant, this
conversion allocates on the heap and copies the
underlying str
. Otherwise, it will try to reuse the owned
String
’s allocation.
§Examples
use std::borrow::Cow;
let unboxed = Cow::Borrowed("hello");
let boxed: Box<str> = Box::from(unboxed);
println!("{boxed}");
let unboxed = Cow::Owned("hello".to_string());
let boxed: Box<str> = Box::from(unboxed);
println!("{boxed}");
1.14.0 · Source§impl<'a, T> From<Cow<'a, [T]>> for Vec<T>
impl<'a, T> From<Cow<'a, [T]>> for Vec<T>
Source§fn from(s: Cow<'a, [T]>) -> Vec<T> ⓘ
fn from(s: Cow<'a, [T]>) -> Vec<T> ⓘ
Converts a clone-on-write slice into a vector.
If s
already owns a Vec<T>
, it will be returned directly.
If s
is borrowing a slice, a new Vec<T>
will be allocated and
filled by cloning s
’s items into it.
§Examples
let o: Cow<'_, [i32]> = Cow::Owned(vec![1, 2, 3]);
let b: Cow<'_, [i32]> = Cow::Borrowed(&[1, 2, 3]);
assert_eq!(Vec::from(o), Vec::from(b));
1.14.0 · Source§impl<'a> From<Cow<'a, str>> for String
impl<'a> From<Cow<'a, str>> for String
Source§fn from(s: Cow<'a, str>) -> String ⓘ
fn from(s: Cow<'a, str>) -> String ⓘ
Converts a clone-on-write string to an owned
instance of String
.
This extracts the owned string, clones the string if it is not already owned.
§Example
// If the string is not owned...
let cow: Cow<'_, str> = Cow::Borrowed("eggplant");
// It will allocate on the heap and copy the string.
let owned: String = String::from(cow);
assert_eq!(&owned[..], "eggplant");
1.22.0 · Source§impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + 'a>
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + 'a>
1.22.0 · Source§impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a>
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a>
Source§fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a>
fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a>
Converts a Cow
into a box of dyn Error
+ Send
+ Sync
.
§Examples
use std::error::Error;
use std::mem;
use std::borrow::Cow;
let a_cow_str_error = Cow::from("a str error");
let a_boxed_error = Box::<dyn Error + Send + Sync>::from(a_cow_str_error);
assert!(
mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
§impl<'a> FromParallelIterator<Cow<'a, OsStr>> for OsString
Collects OS-string slices from a parallel iterator into an OS-string.
impl<'a> FromParallelIterator<Cow<'a, OsStr>> for OsString
Collects OS-string slices from a parallel iterator into an OS-string.
§fn from_par_iter<I>(par_iter: I) -> OsString
fn from_par_iter<I>(par_iter: I) -> OsString
par_iter
. Read more§impl<'a> FromParallelIterator<Cow<'a, str>> for String
Collects string slices from a parallel iterator into a string.
impl<'a> FromParallelIterator<Cow<'a, str>> for String
Collects string slices from a parallel iterator into a string.
§fn from_par_iter<I>(par_iter: I) -> String ⓘ
fn from_par_iter<I>(par_iter: I) -> String ⓘ
par_iter
. Read more§impl<'a, C, T> FromParallelIterator<T> for Cow<'a, C>
Collects an arbitrary Cow
collection.
impl<'a, C, T> FromParallelIterator<T> for Cow<'a, C>
Collects an arbitrary Cow
collection.
Note, the standard library only has FromIterator
for Cow<'a, str>
and
Cow<'a, [T]>
, because no one thought to add a blanket implementation
before it was stabilized.
§fn from_par_iter<I>(par_iter: I) -> Cow<'a, C>where
I: IntoParallelIterator<Item = T>,
fn from_par_iter<I>(par_iter: I) -> Cow<'a, C>where
I: IntoParallelIterator<Item = T>,
par_iter
. Read more§impl<'a> FromPyObjectBound<'a, '_> for Cow<'a, [u8]>
Special-purpose trait impl to efficiently handle both bytes
and bytearray
impl<'a> FromPyObjectBound<'a, '_> for Cow<'a, [u8]>
Special-purpose trait impl to efficiently handle both bytes
and bytearray
If the source object is a bytes
object, the Cow
will be borrowed and
pointing into the source object, and no copying or heap allocations will happen.
If it is a bytearray
, its contents will be copied to an owned Cow
.
§impl<'a> FromPyObjectBound<'a, '_> for Cow<'a, str>
impl<'a> FromPyObjectBound<'a, '_> for Cow<'a, str>
Source§impl<'de, 'a, E> IntoDeserializer<'de, E> for Cow<'a, str>where
E: Error,
impl<'de, 'a, E> IntoDeserializer<'de, E> for Cow<'a, str>where
E: Error,
Source§type Deserializer = CowStrDeserializer<'a, E>
type Deserializer = CowStrDeserializer<'a, E>
Source§fn into_deserializer(self) -> CowStrDeserializer<'a, E>
fn into_deserializer(self) -> CowStrDeserializer<'a, E>
§impl<'py> IntoPyObject<'py> for &Cow<'_, OsStr>
impl<'py> IntoPyObject<'py> for &Cow<'_, OsStr>
§type Output = Bound<'py, <&Cow<'_, OsStr> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <&Cow<'_, OsStr> as IntoPyObject<'py>>::Target>
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<&Cow<'_, OsStr> as IntoPyObject<'py>>::Output, <&Cow<'_, OsStr> as IntoPyObject<'py>>::Error> ⓘ
fn into_pyobject( self, py: Python<'py>, ) -> Result<<&Cow<'_, OsStr> as IntoPyObject<'py>>::Output, <&Cow<'_, OsStr> as IntoPyObject<'py>>::Error> ⓘ
§impl<'py> IntoPyObject<'py> for &Cow<'_, Path>
impl<'py> IntoPyObject<'py> for &Cow<'_, Path>
§type Output = Bound<'py, <&Cow<'_, Path> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <&Cow<'_, Path> as IntoPyObject<'py>>::Target>
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<&Cow<'_, Path> as IntoPyObject<'py>>::Output, <&Cow<'_, Path> as IntoPyObject<'py>>::Error> ⓘ
fn into_pyobject( self, py: Python<'py>, ) -> Result<<&Cow<'_, Path> as IntoPyObject<'py>>::Output, <&Cow<'_, Path> as IntoPyObject<'py>>::Error> ⓘ
§impl<'py> IntoPyObject<'py> for &Cow<'_, str>
impl<'py> IntoPyObject<'py> for &Cow<'_, str>
§type Output = Bound<'py, <&Cow<'_, str> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <&Cow<'_, str> as IntoPyObject<'py>>::Target>
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<&Cow<'_, str> as IntoPyObject<'py>>::Output, <&Cow<'_, str> as IntoPyObject<'py>>::Error> ⓘ
fn into_pyobject( self, py: Python<'py>, ) -> Result<<&Cow<'_, str> as IntoPyObject<'py>>::Output, <&Cow<'_, str> as IntoPyObject<'py>>::Error> ⓘ
§impl<'py, T> IntoPyObject<'py> for Cow<'_, [T]>
impl<'py, T> IntoPyObject<'py> for Cow<'_, [T]>
§impl<'py> IntoPyObject<'py> for Cow<'_, OsStr>
impl<'py> IntoPyObject<'py> for Cow<'_, OsStr>
§type Output = Bound<'py, <Cow<'_, OsStr> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Cow<'_, OsStr> as IntoPyObject<'py>>::Target>
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Cow<'_, OsStr> as IntoPyObject<'py>>::Output, <Cow<'_, OsStr> as IntoPyObject<'py>>::Error> ⓘ
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Cow<'_, OsStr> as IntoPyObject<'py>>::Output, <Cow<'_, OsStr> as IntoPyObject<'py>>::Error> ⓘ
§impl<'py> IntoPyObject<'py> for Cow<'_, Path>
impl<'py> IntoPyObject<'py> for Cow<'_, Path>
§type Output = Bound<'py, <Cow<'_, Path> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Cow<'_, Path> as IntoPyObject<'py>>::Target>
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Cow<'_, Path> as IntoPyObject<'py>>::Output, <Cow<'_, Path> as IntoPyObject<'py>>::Error> ⓘ
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Cow<'_, Path> as IntoPyObject<'py>>::Output, <Cow<'_, Path> as IntoPyObject<'py>>::Error> ⓘ
§impl<'py> IntoPyObject<'py> for Cow<'_, str>
impl<'py> IntoPyObject<'py> for Cow<'_, str>
§type Output = Bound<'py, <Cow<'_, str> as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <Cow<'_, str> as IntoPyObject<'py>>::Target>
§type Error = Infallible
type Error = Infallible
§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Cow<'_, str> as IntoPyObject<'py>>::Output, <Cow<'_, str> as IntoPyObject<'py>>::Error> ⓘ
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Cow<'_, str> as IntoPyObject<'py>>::Output, <Cow<'_, str> as IntoPyObject<'py>>::Error> ⓘ
1.0.0 · Source§impl<B> Ord for Cow<'_, B>
impl<B> Ord for Cow<'_, B>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
§impl<'a> ParallelExtend<Cow<'a, OsStr>> for OsString
Extends an OS-string with string slices from a parallel iterator.
impl<'a> ParallelExtend<Cow<'a, OsStr>> for OsString
Extends an OS-string with string slices from a parallel iterator.
§fn par_extend<I>(&mut self, par_iter: I)
fn par_extend<I>(&mut self, par_iter: I)
par_iter
. Read more§impl<'a> ParallelExtend<Cow<'a, str>> for String
Extends a string with string slices from a parallel iterator.
impl<'a> ParallelExtend<Cow<'a, str>> for String
Extends a string with string slices from a parallel iterator.
§fn par_extend<I>(&mut self, par_iter: I)
fn par_extend<I>(&mut self, par_iter: I)
par_iter
. Read more1.8.0 · Source§impl<'a, 'b> PartialOrd<&'b OsStr> for Cow<'a, OsStr>
impl<'a, 'b> PartialOrd<&'b OsStr> for Cow<'a, OsStr>
1.8.0 · Source§impl<'a, 'b> PartialOrd<&'b OsStr> for Cow<'a, Path>
impl<'a, 'b> PartialOrd<&'b OsStr> for Cow<'a, Path>
1.8.0 · Source§impl<'a, 'b> PartialOrd<&'b Path> for Cow<'a, Path>
impl<'a, 'b> PartialOrd<&'b Path> for Cow<'a, Path>
1.8.0 · Source§impl<'a, 'b> PartialOrd<&'a Path> for Cow<'b, OsStr>
impl<'a, 'b> PartialOrd<&'a Path> for Cow<'b, OsStr>
1.8.0 · Source§impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for &'b OsStr
impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for &'b OsStr
1.8.0 · Source§impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for OsStr
impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for OsStr
1.8.0 · Source§impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for OsString
impl<'a, 'b> PartialOrd<Cow<'a, OsStr>> for OsString
1.8.0 · Source§impl<'a> PartialOrd<Cow<'a, OsStr>> for Path
impl<'a> PartialOrd<Cow<'a, OsStr>> for Path
1.8.0 · Source§impl<'a> PartialOrd<Cow<'a, OsStr>> for PathBuf
impl<'a> PartialOrd<Cow<'a, OsStr>> for PathBuf
1.8.0 · Source§impl<'a, 'b> PartialOrd<Cow<'a, Path>> for &'b OsStr
impl<'a, 'b> PartialOrd<Cow<'a, Path>> for &'b OsStr
1.8.0 · Source§impl<'a, 'b> PartialOrd<Cow<'a, Path>> for &'b Path
impl<'a, 'b> PartialOrd<Cow<'a, Path>> for &'b Path
1.8.0 · Source§impl<'a> PartialOrd<Cow<'a, Path>> for OsStr
impl<'a> PartialOrd<Cow<'a, Path>> for OsStr
1.8.0 · Source§impl<'a> PartialOrd<Cow<'a, Path>> for OsString
impl<'a> PartialOrd<Cow<'a, Path>> for OsString
1.8.0 · Source§impl<'a> PartialOrd<Cow<'a, Path>> for Path
impl<'a> PartialOrd<Cow<'a, Path>> for Path
1.8.0 · Source§impl<'a> PartialOrd<Cow<'a, Path>> for PathBuf
impl<'a> PartialOrd<Cow<'a, Path>> for PathBuf
1.8.0 · Source§impl<'a, 'b> PartialOrd<Cow<'b, OsStr>> for &'a Path
impl<'a, 'b> PartialOrd<Cow<'b, OsStr>> for &'a Path
1.8.0 · Source§impl<'a, 'b> PartialOrd<OsStr> for Cow<'a, OsStr>
impl<'a, 'b> PartialOrd<OsStr> for Cow<'a, OsStr>
1.8.0 · Source§impl<'a> PartialOrd<OsStr> for Cow<'a, Path>
impl<'a> PartialOrd<OsStr> for Cow<'a, Path>
1.8.0 · Source§impl<'a, 'b> PartialOrd<OsString> for Cow<'a, OsStr>
impl<'a, 'b> PartialOrd<OsString> for Cow<'a, OsStr>
1.8.0 · Source§impl<'a> PartialOrd<OsString> for Cow<'a, Path>
impl<'a> PartialOrd<OsString> for Cow<'a, Path>
1.8.0 · Source§impl<'a> PartialOrd<Path> for Cow<'a, OsStr>
impl<'a> PartialOrd<Path> for Cow<'a, OsStr>
1.8.0 · Source§impl<'a> PartialOrd<Path> for Cow<'a, Path>
impl<'a> PartialOrd<Path> for Cow<'a, Path>
1.8.0 · Source§impl<'a> PartialOrd<PathBuf> for Cow<'a, OsStr>
impl<'a> PartialOrd<PathBuf> for Cow<'a, OsStr>
1.8.0 · Source§impl<'a> PartialOrd<PathBuf> for Cow<'a, Path>
impl<'a> PartialOrd<PathBuf> for Cow<'a, Path>
1.0.0 · Source§impl<'a, B> PartialOrd for Cow<'a, B>
impl<'a, B> PartialOrd for Cow<'a, B>
§impl<'a> Replacer for &'a Cow<'a, str>
impl<'a> Replacer for &'a Cow<'a, str>
§fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String)
fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String)
dst
to replace the current match. Read more§fn no_expansion(&mut self) -> Option<Cow<'_, str>> ⓘ
fn no_expansion(&mut self) -> Option<Cow<'_, str>> ⓘ
§fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self>
fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self>
§impl<'a> Replacer for Cow<'a, str>
impl<'a> Replacer for Cow<'a, str>
§fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String)
fn replace_append(&mut self, caps: &Captures<'_>, dst: &mut String)
dst
to replace the current match. Read more§fn no_expansion(&mut self) -> Option<Cow<'_, str>> ⓘ
fn no_expansion(&mut self) -> Option<Cow<'_, str>> ⓘ
§fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self>
fn by_ref<'r>(&'r mut self) -> ReplacerRef<'r, Self>
Source§impl<'a, T> Serialize for Cow<'a, T>
impl<'a, T> Serialize for Cow<'a, T>
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> ⓘwhere
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> ⓘwhere
S: Serializer,
§impl<'a, T, S> SerializeWith<Cow<'a, [T]>, S> for AsOwned
impl<'a, T, S> SerializeWith<Cow<'a, [T]>, S> for AsOwned
§impl<'a, S> SerializeWith<Cow<'a, CStr>, S> for AsOwned
impl<'a, S> SerializeWith<Cow<'a, CStr>, S> for AsOwned
§impl<'a, F, S> SerializeWith<Cow<'a, F>, S> for AsOwned
impl<'a, F, S> SerializeWith<Cow<'a, F>, S> for AsOwned
§impl<'a, S> SerializeWith<Cow<'a, str>, S> for AsOwned
impl<'a, S> SerializeWith<Cow<'a, str>, S> for AsOwned
§impl ToPyObject for Cow<'_, [u8]>
impl ToPyObject for Cow<'_, [u8]>
§impl ToPyObject for Cow<'_, OsStr>
impl ToPyObject for Cow<'_, OsStr>
§impl ToPyObject for Cow<'_, Path>
impl ToPyObject for Cow<'_, Path>
§impl ToPyObject for Cow<'_, str>
Converts a Rust Cow<'_, str>
to a Python object.
See PyString::new
for details on the conversion.
impl ToPyObject for Cow<'_, str>
Converts a Rust Cow<'_, str>
to a Python object.
See PyString::new
for details on the conversion.
impl<B> DerefPure for Cow<'_, B>
impl<B> Eq for Cow<'_, B>
Auto Trait Implementations§
impl<'a, B> Freeze for Cow<'a, B>
impl<'a, B> RefUnwindSafe for Cow<'a, B>
impl<'a, B> Send for Cow<'a, B>
impl<'a, B> Sync for Cow<'a, B>
impl<'a, B> Unpin for Cow<'a, B>
impl<'a, B> UnwindSafe for Cow<'a, B>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr> ⓘ
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr> ⓘ
self
into an owned Python object, dropping type information.§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<'a, T, N> StringZilla<'a, N> for T
impl<'a, T, N> StringZilla<'a, N> for T
§fn sz_find_char_from(&self, needles: N) -> Option<usize> ⓘ
fn sz_find_char_from(&self, needles: N) -> Option<usize> ⓘ
§fn sz_rfind_char_from(&self, needles: N) -> Option<usize> ⓘ
fn sz_rfind_char_from(&self, needles: N) -> Option<usize> ⓘ
§fn sz_find_char_not_from(&self, needles: N) -> Option<usize> ⓘ
fn sz_find_char_not_from(&self, needles: N) -> Option<usize> ⓘ
§fn sz_rfind_char_not_from(&self, needles: N) -> Option<usize> ⓘ
fn sz_rfind_char_not_from(&self, needles: N) -> Option<usize> ⓘ
§fn sz_edit_distance(&self, other: N) -> usize ⓘ
fn sz_edit_distance(&self, other: N) -> usize ⓘ
§fn sz_alignment_score(
&self,
other: N,
matrix: [[i8; 256]; 256],
gap: i8,
) -> isize ⓘ
fn sz_alignment_score( &self, other: N, matrix: [[i8; 256]; 256], gap: i8, ) -> isize ⓘ
self
and other
using the specified
substitution matrix and gap penalty. Read more§fn sz_matches(&'a self, needle: &'a N) -> RangeMatches<'a> ⓘ
fn sz_matches(&'a self, needle: &'a N) -> RangeMatches<'a> ⓘ
§fn sz_rmatches(&'a self, needle: &'a N) -> RangeRMatches<'a> ⓘ
fn sz_rmatches(&'a self, needle: &'a N) -> RangeRMatches<'a> ⓘ
needle
in self
, searching from the end. Read more§fn sz_splits(&'a self, needle: &'a N) -> RangeSplits<'a> ⓘ
fn sz_splits(&'a self, needle: &'a N) -> RangeSplits<'a> ⓘ
§fn sz_rsplits(&'a self, needle: &'a N) -> RangeRSplits<'a> ⓘ
fn sz_rsplits(&'a self, needle: &'a N) -> RangeRSplits<'a> ⓘ
self
that are separated by the given needle
, searching from the end. Read more§fn sz_find_first_of(&'a self, needles: &'a N) -> RangeMatches<'a> ⓘ
fn sz_find_first_of(&'a self, needles: &'a N) -> RangeMatches<'a> ⓘ
needles
within self
. Read more§fn sz_find_last_of(&'a self, needles: &'a N) -> RangeRMatches<'a> ⓘ
fn sz_find_last_of(&'a self, needles: &'a N) -> RangeRMatches<'a> ⓘ
needles
within self
, searching from the end. Read more§fn sz_find_first_not_of(&'a self, needles: &'a N) -> RangeMatches<'a> ⓘ
fn sz_find_first_not_of(&'a self, needles: &'a N) -> RangeMatches<'a> ⓘ
needles
within self
. Read more§fn sz_find_last_not_of(&'a self, needles: &'a N) -> RangeRMatches<'a> ⓘ
fn sz_find_last_not_of(&'a self, needles: &'a N) -> RangeRMatches<'a> ⓘ
needles
within self
, searching from the end. Read more