pub struct GenRef<'s, M: Mutability, T: ?Sized> { /* private fields */ }Expand description
This is the main type of this crate.
It is the generic-mutability equivalent of safe reference types (& and &mut).
§Usage for end users
You need to interface with an API that is generic over mutability, but you do not use generic mutability to call it.
You will need to create a GenRef<'_, Mutable, T> or GenRef<'_, Shared, T> via the From<&mut T> or From<&T> implementations, respectively.
Then pass the GenRef to the function(s) you would like to call.
At the end, you can use the resulting GenRef mostly the same way you would use a reference, but you can also unwrap it into a normal reference using the into_mut or into_shared functions.
For example:
let v = vec![1, 2, 3];
let gen_r: GenRef<'_, Shared, i32> = gen_index(GenRef::from(&v), 1);
let r: &i32 = GenRef::into_shared(gen_r);
assert_eq!(gen_r, &2);
assert_eq!(r, &2);§Usage for libraries
You are implementing an API that is supposed to be generic over mutability.
You should start by introducing a mutability parameter.
It is a generic argument (usually named M) with a M: Mutability bound on it .
Then you can take a GenRef as an argument.
GenRef always provides immutable access to the pointed-to value through the Deref trait.
Then, to map the generic reference into one of another type, you can do one of these:
-
If the API you are calling has generic mutability accessors, you can pass the
GenRefdirectly to them. Unlike normal references, which are automatically reborrowed, you may need to useGenRef::reborrowto perform a reborrow manually. You can also callmap_derefto perform a dereference. -
If the API you’re calling does not have generic mutability, you can use one of the following ways to unwrap and reconstruct the
GenRef:mapfield!macro for accessing fieldsgen_mut!macro- branch to cases on
Mutability::mutability()and usegen_{into,from}_{mut,shared}with the proof provided by the return value ofMutability::mutability(). See the Examples section on how to do this.
§Examples
When you need to map a generic GenRef through an API that doesn’t support it, you can use the following pattern:
fn gen_index<M: Mutability, T>(gen_slice: GenRef<'_, M, [T]>, index: usize) -> GenRef<'_, M, T> {
match M::mutability() {
Mutable(proof) => {
let mut_slice: &mut [T] = GenRef::gen_into_mut(gen_slice, proof);
let mut_elem: &mut T = &mut mut_slice[index];
GenRef::gen_from_mut(mut_elem, proof)
},
Shared(proof) => {
let ref_slice: &[T] = GenRef::gen_into_shared(gen_slice, proof);
let ref_elem: &T = &ref_slice[index];
GenRef::gen_from_shared(ref_elem, proof)
}
}
}In most cases, the mutable and shared cases share most of the code. When that is the case, it is often possible to use the gen_mut! macro, which expands to the same as above:
fn gen_index<M: Mutability, T>(gen_slice: GenRef<'_, M, [T]>, index: usize) -> GenRef<'_, M, T> {
gen_mut!(M => {
let ref_slice = from_gen!(gen_slice);
into_gen!(&gen ref_slice[index])
})
}When performing a one-to-one mapping with two separate functions (often when calling into an API), the GenRef::map can come handy:
fn gen_index<M: Mutability, T>(gen_slice: GenRef<'_, M, [T]>, index: usize) -> GenRef<'_, M, T> {
GenRef::map(gen_slice, |r| &r[index], |r| &mut r[index])
}Finally, when accessing fields or performing indexing, the field! macro can be helpful as well:
fn gen_index<M: Mutability, T>(gen_slice: GenRef<'_, M, [T]>, index: usize) -> GenRef<'_, M, T> {
field!(&gen gen_slice[index])
}Implementations§
Source§impl<'s, M: Mutability, T: ?Sized> GenRef<'s, M, T>
impl<'s, M: Mutability, T: ?Sized> GenRef<'s, M, T>
Sourcepub unsafe fn from_ptr_unchecked(ptr: NonNull<T>) -> Self
pub unsafe fn from_ptr_unchecked(ptr: NonNull<T>) -> Self
Creates a GenRef<'s, M, T> from a pointer with the chosen mutability M and lifetime 's, without checking.
To create a non-generic GenRef from a reference, use the From implementation.
To convert a reference into a GenRef in a generic context, use the gen_from_shared and gen_from_mut methods with a proof or the gen_from_mut_downgrading method instead.
§Safety
GenRef is a safe reference type. Using this method is equivalent to dereferencing the pointer and creating a reference from it. As such:
- The pointer must be properly aligned.
- The pointer must point to an initialized instance of
T. - The lifetime
'sand mutabilityMare arbitrarily chosen and do not necessarily reflect the actual lifetime and mutability of the data. Extra care must be taken to ensure that the correct lifetime and mutability parameters are used. - Furthermore:
- If the mutability is
Immutable:- The pointer must be valid for reads for lifetime
's. - The pointed-to value must not be written to by other pointers and no mutable references to it may exist during
's.
- The pointer must be valid for reads for lifetime
- If the mutability is
Mutable:- The pointer must be valid for reads and writes for lifetime
's. - The pointed-to value must not be accessed (read or written) by other pointers, and no other references to it may exist during
's.
- The pointer must be valid for reads and writes for lifetime
- If the mutability is
Sourcepub fn gen_from_mut_downgrading(reference: &'s mut T) -> Self
pub fn gen_from_mut_downgrading(reference: &'s mut T) -> Self
Converts a &mut T into a generic GenRef<'_, M, T>, downgrading the reference if M is Shared.
If M is Mutable it behaves exactly the same way as gen_from_mut without requiring a proof for mutability.
In this case, the difference between the two is purely semantic: if you have proof that M is Mutable, you should use gen_from_mut.
Converts a generic GenRef<'_, M, T> into &T, downgrading the reference if M is Mutable.
If M is Shared it behaves exactly the same way as gen_into_shared without requiring a proof for sharedness.
In this case, the difference between the two is purely semantic: if you have proof that M is Shared, you should use gen_into_shared.
Sourcepub fn gen_into_mut(genref: Self, _proof: IsMutable<M>) -> &'s mut T
pub fn gen_into_mut(genref: Self, _proof: IsMutable<M>) -> &'s mut T
Converts a generic GenRef<'_, M, T> into &mut T.
This is available in a generic context.
Once the transformations are done, the result can be converted back into a GenRef using the gen_from_mut function.
The conversion requires that M is Mutable, this must be proven by passing an IsMutable<M> value.
That can be obtained by matching on M::mutability().
Sourcepub fn gen_from_mut(reference: &'s mut T, _proof: IsMutable<M>) -> Self
pub fn gen_from_mut(reference: &'s mut T, _proof: IsMutable<M>) -> Self
Converts a &mut T into a generic GenRef<'_, M, T>.
This is available in a generic context.
The conversion requires that M is Mutable, this must be proven by passing an IsMutable<M> value.
That can be obtained by matching on M::mutability().
If you want to force the conversion even if M is Shared, you can use the gen_from_mut_downgrading function.
Converts a generic GenRef<'_, M, T> into &T.
This is available in a generic context.
Once the transformations are done, the result can be converted back into a GenRef using the gen_from_shared function.
The conversion requires that M is Shared, this must be proven by passing an IsShared<M> value.
That can be obtained by matching on M::mutability().
If you want to force the conversion even if M is Mutable, you can use the gen_into_shared_downgrading function.
Converts a &T into a generic GenRef<'_, M, T>.
This is available in a generic context.
The conversion requires that M is Shared, this must be proven by passing an IsShared<M> value.
That can be obtained by matching on M::mutability().
Sourcepub fn reborrow(genref: &mut Self) -> GenRef<'_, M, T>
pub fn reborrow(genref: &mut Self) -> GenRef<'_, M, T>
Generically reborrows a GenRef.
That is, it creates a shorter-lived owned GenRef from a &mut GenRef.
This is available in a generic context.
This requires the variable to be marked mut, even if M is Shared and thus no mutation takes place.
Sourcepub fn map<U: ?Sized>(
genref: Self,
f_shared: impl FnOnce(&T) -> &U,
f_mut: impl FnOnce(&mut T) -> &mut U,
) -> GenRef<'s, M, U>
pub fn map<U: ?Sized>( genref: Self, f_shared: impl FnOnce(&T) -> &U, f_mut: impl FnOnce(&mut T) -> &mut U, ) -> GenRef<'s, M, U>
Maps a generic GenRef into another one using either f_mut or f_shared.
This is available in a generic context.
Using this function is usually sufficient.
For mapping over field access, you can use the field! macro instead.
If you need more flexibility, you can use the gen_mut! macro or matching over M::mutability().
Converts a GenRef<'_, Shared, T> into &T in a non-generic context.
This is used to unwrap the reference in end-user code.
To perform the same operation in a generic context, use gen_into_shared or gen_into_shared_downgrading.
Trait Implementations§
Source§impl<'s, M: Mutability, T> Binary for GenRef<'s, M, T>
impl<'s, M: Mutability, T> Binary for GenRef<'s, M, T>
Source§impl<T: ?Sized> BorrowMut<T> for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T: ?Sized> BorrowMut<T> for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BufRead for GenRef<'_, Mutable, T>
Available on crate features std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> BufRead for GenRef<'_, Mutable, T>
std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
This is only available with the feature flag std.
Source§fn fill_buf(&mut self) -> Result<&[u8]>
fn fill_buf(&mut self) -> Result<&[u8]>
Read methods, if empty. Read moreSource§fn consume(&mut self, amt: usize)
fn consume(&mut self, amt: usize)
amount of additional bytes from the internal buffer as having been read.
Subsequent calls to read only return bytes that have not been marked as read. Read moreSource§fn has_data_left(&mut self) -> Result<bool, Error>
fn has_data_left(&mut self) -> Result<bool, Error>
buf_read_has_data_left)read. Read more1.83.0 · Source§fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
fn skip_until(&mut self, byte: u8) -> Result<usize, Error>
byte or EOF is reached. Read more1.0.0 · Source§fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_line(&mut self, buf: &mut String) -> Result<usize, Error>
0xA byte) is reached, and append
them to the provided String buffer. Read moreSource§impl<'s, M: Mutability, T> Debug for GenRef<'s, M, T>
impl<'s, M: Mutability, T> Debug for GenRef<'s, M, T>
Source§impl<M: Mutability, T: ?Sized> Deref for GenRef<'_, M, T>
This is available in a generic context.
impl<M: Mutability, T: ?Sized> Deref for GenRef<'_, M, T>
This is available in a generic context.
Source§impl<T: ?Sized> DerefMut for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T: ?Sized> DerefMut for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
To get mutable access to the value, call reborrow followed by gen_into_mut (this requires proving that M is mutable).
Source§impl<'s, M: Mutability, T> Display for GenRef<'s, M, T>
impl<'s, M: Mutability, T> Display for GenRef<'s, M, T>
Source§impl<T> DoubleEndedIterator for GenRef<'_, Mutable, T>where
T: DoubleEndedIterator + ?Sized,
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> DoubleEndedIterator for GenRef<'_, Mutable, T>where
T: DoubleEndedIterator + ?Sized,
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
Source§fn next_back(&mut self) -> Option<Self::Item>
fn next_back(&mut self) -> Option<Self::Item>
Source§fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn advance_back_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
iter_advance_by)n elements. Read more1.37.0 · Source§fn nth_back(&mut self, n: usize) -> Option<Self::Item>
fn nth_back(&mut self, n: usize) -> Option<Self::Item>
nth element from the end of the iterator. Read more1.27.0 · Source§fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R
Iterator::try_fold(): it takes
elements starting from the back of the iterator. Read moreSource§impl<T> ExactSizeIterator for GenRef<'_, Mutable, T>where
T: ExactSizeIterator + ?Sized,
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> ExactSizeIterator for GenRef<'_, Mutable, T>where
T: ExactSizeIterator + ?Sized,
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
This is used to create a GenRef in end-user code.
To create a generic GenRef<'_, M, T>, use gen_from_shared.
Source§impl<'s, T: ?Sized> From<&'s mut T> for GenRef<'s, Mutable, T>
Creates a non-generic GenRef<'_, Mutable, T> from a &mut T.
impl<'s, T: ?Sized> From<&'s mut T> for GenRef<'s, Mutable, T>
Creates a non-generic GenRef<'_, Mutable, T> from a &mut T.
This is used to create a GenRef in end-user code.
To create a generic GenRef<'_, M, T>, use gen_from_mut or gen_from_mut_downgrading.
Source§impl<'s, M: Mutability, T: ?Sized> GenRefMethods<'s, M, T> for GenRef<'s, M, T>
impl<'s, M: Mutability, T: ?Sized> GenRefMethods<'s, M, T> for GenRef<'s, M, T>
Source§fn as_ptr(&self) -> NonNull<T>
fn as_ptr(&self) -> NonNull<T>
GenRef.
Casts the reference into a NonNull pointer. Read moreGenRef.
Converts a generic GenRef<'_, M, T> into &T, downgrading the reference if M is Mutable. Read moreSource§fn gen_into_mut(self, proof: IsMutable<M>) -> &'s mut T
fn gen_into_mut(self, proof: IsMutable<M>) -> &'s mut T
GenRef.
Converts a generic GenRef<'_, M, T> into &mut T.
This is available in a generic context. Read moreGenRef.
Converts a generic GenRef<'_, M, T> into &T.
This is available in a generic context. Read moreSource§fn reborrow(&mut self) -> GenRef<'_, M, T>
fn reborrow(&mut self) -> GenRef<'_, M, T>
GenRef.
Generically reborrows a GenRef.
That is, it creates a shorter-lived owned GenRef from a &mut GenRef.
This is available in a generic context. Read moreSource§fn map<U: ?Sized>(
self,
f_mut: impl FnOnce(&mut T) -> &mut U,
f_shared: impl FnOnce(&T) -> &U,
) -> GenRef<'s, M, U>
fn map<U: ?Sized>( self, f_mut: impl FnOnce(&mut T) -> &mut U, f_shared: impl FnOnce(&T) -> &U, ) -> GenRef<'s, M, U>
GenRef.
Maps a generic GenRef into another one using either f_mut or f_shared.
This is available in a generic context. Read moreSource§impl<M: Mutability, T> Hash for GenRef<'_, M, T>
impl<M: Mutability, T> Hash for GenRef<'_, M, T>
Source§impl<T> Iterator for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> Iterator for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
Source§fn next(&mut self) -> Option<Self::Item>
fn next(&mut self) -> Option<Self::Item>
Source§fn nth(&mut self, n: usize) -> Option<Self::Item>
fn nth(&mut self, n: usize) -> Option<Self::Item>
nth element of the iterator. Read moreSource§fn size_hint(&self) -> (usize, Option<usize>)
fn size_hint(&self) -> (usize, Option<usize>)
Source§fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
fn next_chunk<const N: usize>(
&mut self,
) -> Result<[Self::Item; N], IntoIter<Self::Item, N>>where
Self: Sized,
iter_next_chunk)N values. Read more1.0.0 · Source§fn count(self) -> usizewhere
Self: Sized,
fn count(self) -> usizewhere
Self: Sized,
1.0.0 · Source§fn last(self) -> Option<Self::Item>where
Self: Sized,
fn last(self) -> Option<Self::Item>where
Self: Sized,
Source§fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
fn advance_by(&mut self, n: usize) -> Result<(), NonZero<usize>>
iter_advance_by)n elements. Read more1.28.0 · Source§fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
fn step_by(self, step: usize) -> StepBy<Self>where
Self: Sized,
1.0.0 · Source§fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
fn chain<U>(self, other: U) -> Chain<Self, <U as IntoIterator>::IntoIter>
1.0.0 · Source§fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
fn zip<U>(self, other: U) -> Zip<Self, <U as IntoIterator>::IntoIter>where
Self: Sized,
U: IntoIterator,
Source§fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
fn intersperse(self, separator: Self::Item) -> Intersperse<Self>
iter_intersperse)separator between adjacent
items of the original iterator. Read moreSource§fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
fn intersperse_with<G>(self, separator: G) -> IntersperseWith<Self, G>
iter_intersperse)separator
between adjacent items of the original iterator. Read more1.0.0 · Source§fn map<B, F>(self, f: F) -> Map<Self, F>
fn map<B, F>(self, f: F) -> Map<Self, F>
1.0.0 · Source§fn filter<P>(self, predicate: P) -> Filter<Self, P>
fn filter<P>(self, predicate: P) -> Filter<Self, P>
1.0.0 · Source§fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F>
1.0.0 · Source§fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
fn enumerate(self) -> Enumerate<Self>where
Self: Sized,
1.0.0 · Source§fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
fn skip_while<P>(self, predicate: P) -> SkipWhile<Self, P>
1.0.0 · Source§fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
fn take_while<P>(self, predicate: P) -> TakeWhile<Self, P>
1.57.0 · Source§fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>
1.0.0 · Source§fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
fn skip(self, n: usize) -> Skip<Self>where
Self: Sized,
n elements. Read more1.0.0 · Source§fn take(self, n: usize) -> Take<Self>where
Self: Sized,
fn take(self, n: usize) -> Take<Self>where
Self: Sized,
n elements, or fewer
if the underlying iterator ends sooner. Read more1.0.0 · Source§fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
fn flat_map<U, F>(self, f: F) -> FlatMap<Self, U, F>
1.29.0 · Source§fn flatten(self) -> Flatten<Self>
fn flatten(self) -> Flatten<Self>
Source§fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
fn map_windows<F, R, const N: usize>(self, f: F) -> MapWindows<Self, F, N>
iter_map_windows)f for each contiguous window of size N over
self and returns an iterator over the outputs of f. Like slice::windows(),
the windows during mapping overlap as well. Read more1.0.0 · Source§fn inspect<F>(self, f: F) -> Inspect<Self, F>
fn inspect<F>(self, f: F) -> Inspect<Self, F>
1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Iterator. Read moreSource§fn try_collect<B>(
&mut self,
) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
fn try_collect<B>( &mut self, ) -> <<Self::Item as Try>::Residual as Residual<B>>::TryType
iterator_try_collect)Source§fn collect_into<E>(self, collection: &mut E) -> &mut E
fn collect_into<E>(self, collection: &mut E) -> &mut E
iter_collect_into)1.0.0 · Source§fn partition<B, F>(self, f: F) -> (B, B)
fn partition<B, F>(self, f: F) -> (B, B)
Source§fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
fn partition_in_place<'a, T, P>(self, predicate: P) -> usize
iter_partition_in_place)true precede all those that return false.
Returns the number of true elements found. Read moreSource§fn is_partitioned<P>(self, predicate: P) -> bool
fn is_partitioned<P>(self, predicate: P) -> bool
iter_is_partitioned)true precede all those that return false. Read more1.27.0 · Source§fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R
1.27.0 · Source§fn try_for_each<F, R>(&mut self, f: F) -> R
fn try_for_each<F, R>(&mut self, f: F) -> R
1.0.0 · Source§fn fold<B, F>(self, init: B, f: F) -> B
fn fold<B, F>(self, init: B, f: F) -> B
1.51.0 · Source§fn reduce<F>(self, f: F) -> Option<Self::Item>
fn reduce<F>(self, f: F) -> Option<Self::Item>
Source§fn try_reduce<R>(
&mut self,
f: impl FnMut(Self::Item, Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
fn try_reduce<R>( &mut self, f: impl FnMut(Self::Item, Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<<R as Try>::Output>>>::TryType
iterator_try_reduce)1.0.0 · Source§fn all<F>(&mut self, f: F) -> bool
fn all<F>(&mut self, f: F) -> bool
1.0.0 · Source§fn any<F>(&mut self, f: F) -> bool
fn any<F>(&mut self, f: F) -> bool
1.0.0 · Source§fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
fn find<P>(&mut self, predicate: P) -> Option<Self::Item>
1.30.0 · Source§fn find_map<B, F>(&mut self, f: F) -> Option<B>
fn find_map<B, F>(&mut self, f: F) -> Option<B>
Source§fn try_find<R>(
&mut self,
f: impl FnMut(&Self::Item) -> R,
) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
fn try_find<R>( &mut self, f: impl FnMut(&Self::Item) -> R, ) -> <<R as Try>::Residual as Residual<Option<Self::Item>>>::TryType
try_find)1.0.0 · Source§fn position<P>(&mut self, predicate: P) -> Option<usize>
fn position<P>(&mut self, predicate: P) -> Option<usize>
1.0.0 · Source§fn rposition<P>(&mut self, predicate: P) -> Option<usize>
fn rposition<P>(&mut self, predicate: P) -> Option<usize>
1.0.0 · Source§fn max(self) -> Option<Self::Item>
fn max(self) -> Option<Self::Item>
1.0.0 · Source§fn min(self) -> Option<Self::Item>
fn min(self) -> Option<Self::Item>
1.6.0 · Source§fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn max_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · Source§fn max_by<F>(self, compare: F) -> Option<Self::Item>
fn max_by<F>(self, compare: F) -> Option<Self::Item>
1.6.0 · Source§fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
fn min_by_key<B, F>(self, f: F) -> Option<Self::Item>
1.15.0 · Source§fn min_by<F>(self, compare: F) -> Option<Self::Item>
fn min_by<F>(self, compare: F) -> Option<Self::Item>
1.0.0 · Source§fn rev(self) -> Rev<Self>where
Self: Sized + DoubleEndedIterator,
fn rev(self) -> Rev<Self>where
Self: Sized + DoubleEndedIterator,
1.0.0 · Source§fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB)
1.36.0 · Source§fn copied<'a, T>(self) -> Copied<Self>
fn copied<'a, T>(self) -> Copied<Self>
Source§fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>where
Self: Sized,
iter_array_chunks)N elements of the iterator at a time. Read more1.11.0 · Source§fn product<P>(self) -> P
fn product<P>(self) -> P
Source§fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
fn cmp_by<I, F>(self, other: I, cmp: F) -> Ordering
iter_order_by)Iterator with those
of another with respect to the specified comparison function. Read more1.5.0 · Source§fn partial_cmp<I>(self, other: I) -> Option<Ordering>
fn partial_cmp<I>(self, other: I) -> Option<Ordering>
PartialOrd elements of
this Iterator with those of another. The comparison works like short-circuit
evaluation, returning a result without comparing the remaining elements.
As soon as an order can be determined, the evaluation stops and a result is returned. Read moreSource§fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
fn partial_cmp_by<I, F>(self, other: I, partial_cmp: F) -> Option<Ordering>where
Self: Sized,
I: IntoIterator,
F: FnMut(Self::Item, <I as IntoIterator>::Item) -> Option<Ordering>,
iter_order_by)Iterator with those
of another with respect to the specified comparison function. Read moreSource§fn eq_by<I, F>(self, other: I, eq: F) -> bool
fn eq_by<I, F>(self, other: I, eq: F) -> bool
iter_order_by)1.5.0 · Source§fn lt<I>(self, other: I) -> bool
fn lt<I>(self, other: I) -> bool
Iterator are lexicographically
less than those of another. Read more1.5.0 · Source§fn le<I>(self, other: I) -> bool
fn le<I>(self, other: I) -> bool
Iterator are lexicographically
less or equal to those of another. Read more1.5.0 · Source§fn gt<I>(self, other: I) -> bool
fn gt<I>(self, other: I) -> bool
Iterator are lexicographically
greater than those of another. Read more1.5.0 · Source§fn ge<I>(self, other: I) -> bool
fn ge<I>(self, other: I) -> bool
Iterator are lexicographically
greater than or equal to those of another. Read more1.82.0 · Source§fn is_sorted(self) -> bool
fn is_sorted(self) -> bool
1.82.0 · Source§fn is_sorted_by<F>(self, compare: F) -> bool
fn is_sorted_by<F>(self, compare: F) -> bool
1.82.0 · Source§fn is_sorted_by_key<F, K>(self, f: F) -> bool
fn is_sorted_by_key<F, K>(self, f: F) -> bool
Source§impl<'s, M: Mutability, T> LowerExp for GenRef<'s, M, T>
impl<'s, M: Mutability, T> LowerExp for GenRef<'s, M, T>
Source§impl<'s, M: Mutability, T> LowerHex for GenRef<'s, M, T>
impl<'s, M: Mutability, T> LowerHex for GenRef<'s, M, T>
Source§impl<'s, M: Mutability, T> Octal for GenRef<'s, M, T>
impl<'s, M: Mutability, T> Octal for GenRef<'s, M, T>
Source§impl<MT: Mutability, T> Ord for GenRef<'_, MT, T>
impl<MT: Mutability, T> Ord for GenRef<'_, MT, T>
Source§impl<MT: Mutability, MU: Mutability, T, U: ?Sized> PartialEq<GenRef<'_, MU, U>> for GenRef<'_, MT, T>
impl<MT: Mutability, MU: Mutability, T, U: ?Sized> PartialEq<GenRef<'_, MU, U>> for GenRef<'_, MT, T>
Source§impl<MT: Mutability, T, U: ?Sized> PartialOrd<&U> for GenRef<'_, MT, T>where
T: PartialOrd<U> + ?Sized,
impl<MT: Mutability, T, U: ?Sized> PartialOrd<&U> for GenRef<'_, MT, T>where
T: PartialOrd<U> + ?Sized,
Source§impl<MT: Mutability, T, U: ?Sized> PartialOrd<&mut U> for GenRef<'_, MT, T>where
T: PartialOrd<U> + ?Sized,
impl<MT: Mutability, T, U: ?Sized> PartialOrd<&mut U> for GenRef<'_, MT, T>where
T: PartialOrd<U> + ?Sized,
Source§impl<MT: Mutability, MU: Mutability, T, U: ?Sized> PartialOrd<GenRef<'_, MU, U>> for GenRef<'_, MT, T>where
T: PartialOrd<U> + ?Sized,
impl<MT: Mutability, MU: Mutability, T, U: ?Sized> PartialOrd<GenRef<'_, MU, U>> for GenRef<'_, MT, T>where
T: PartialOrd<U> + ?Sized,
Source§impl<T> Read for GenRef<'_, Mutable, T>
Available on crate features std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> Read for GenRef<'_, Mutable, T>
std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
This is only available with the feature flag std.
Source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · Source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read, except that it reads into a slice of buffers. Read moreSource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
buf. Read more1.0.0 · Source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf. Read more1.6.0 · Source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf. Read moreSource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf)cursor. Read more1.0.0 · Source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read. Read more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R>
fn chain<R>(self, next: R) -> Chain<Self, R>
Source§impl<T> Seek for GenRef<'_, Mutable, T>
Available on crate features std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> Seek for GenRef<'_, Mutable, T>
std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
This is only available with the feature flag std.
Source§fn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
1.55.0 · Source§fn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Source§fn stream_len(&mut self) -> Result<u64, Error>
fn stream_len(&mut self) -> Result<u64, Error>
seek_stream_len)This is only available with the feature flag std.
Source§type Iter = <T as ToSocketAddrs>::Iter
type Iter = <T as ToSocketAddrs>::Iter
Source§fn to_socket_addrs(&self) -> Result<Self::Iter>
fn to_socket_addrs(&self) -> Result<Self::Iter>
SocketAddrs. Read moreSource§impl<'s, M: Mutability, T> UpperExp for GenRef<'s, M, T>
impl<'s, M: Mutability, T> UpperExp for GenRef<'s, M, T>
Source§impl<'s, M: Mutability, T> UpperHex for GenRef<'s, M, T>
impl<'s, M: Mutability, T> UpperHex for GenRef<'s, M, T>
Source§impl<T> Write for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> Write for GenRef<'_, Mutable, T>
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
Source§impl<T> Write for GenRef<'_, Mutable, T>
Available on crate features std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<T> Write for GenRef<'_, Mutable, T>
std only.This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
This is only available with the feature flag std.
Source§fn write(&mut self, buf: &[u8]) -> Result<usize>
fn write(&mut self, buf: &[u8]) -> Result<usize>
Source§fn flush(&mut self) -> Result<()>
fn flush(&mut self) -> Result<()>
Source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
can_vector)1.0.0 · Source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
write_all_vectored)impl<M: Mutability, T> Eq for GenRef<'_, M, T>
impl<T> FusedIterator for GenRef<'_, Mutable, T>where
T: FusedIterator + ?Sized,
This is only implemented for GenRef<'_, Mutable, T>, and is not available in a generic context.
impl<M: Mutability, T> Send for GenRef<'_, M, T>
This implementation requires T: Sync even when M is Mutable.
With specialisation, this requirement could be lifted.