reference - Rust (original) (raw)
Primitive Type reference1.0.0 [−]
References, both shared and mutable.
A reference represents a borrow of some owned value. You can get one by using the &
or &mut
operators on a value, or by using a ref
or ref mut
pattern.
For those familiar with pointers, a reference is just a pointer that is assumed to not be null. In fact, Option<&T>
has the same memory representation as a nullable pointer, and can be passed across FFI boundaries as such.
In most cases, references can be used much like the original value. Field access, method calling, and indexing work the same (save for mutability rules, of course). In addition, the comparison operators transparently defer to the referent's implementation, allowing references to be compared the same as owned values.
References have a lifetime attached to them, which represents the scope for which the borrow is valid. A lifetime is said to "outlive" another one if its representative scope is as long or longer than the other. The 'static
lifetime is the longest lifetime, which represents the total life of the program. For example, string literals have a 'static
lifetime because the text data is embedded into the binary of the program, rather than in an allocation that needs to be dynamically managed.
&mut T
references can be freely coerced into &T
references with the same referent type, and references with longer lifetimes can be freely coerced into references with shorter ones.
For more information on how to use references, see the book's section on "References and Borrowing".
The following traits are implemented for all &T
, regardless of the type of its referent:
- Copy
- Clone (Note that this will not defer to
T
'sClone
implementation if it exists!) - Deref
- Borrow
- Pointer
&mut T
references get all of the above except Copy
and Clone
(to prevent creating multiple simultaneous mutable borrows), plus the following, regardless of the type of its referent:
The following traits are implemented on &T
references if the underlying T
also implements that trait:
- All the traits in std::fmt except Pointer and fmt::Write
- PartialOrd
- Ord
- PartialEq
- Eq
- AsRef
- Fn (in addition,
&T
references get FnMut and FnOnce ifT: Fn
) - Hash
- ToSocketAddrs
&mut T
references get all of the above except ToSocketAddrs
, plus the following, if T
implements that trait:
- AsMut
- FnMut (in addition,
&mut T
references get FnOnce ifT: FnMut
) - fmt::Write
- Iterator
- DoubleEndedIterator
- ExactSizeIterator
- FusedIterator
- TrustedLen
- Send (note that
&T
references only getSend
ifT: Sync
) - io::Write
- Read
- Seek
- BufRead
Note that due to method call deref coercion, simply calling a trait method will act like they work on references as well as they do on owned values! The implementations described here are meant for generic contexts, where the final type T
is a type parameter or otherwise not locally known.
`impl<'a, T> Pointer for &'a mut T where
`impl<'a, T> Pointer for &'a T where
`impl<'a, T> Binary for &'a T where
`impl<'a, T> Binary for &'a mut T where
`impl<'a, T> Debug for &'a mut T where
`impl<'a, T> Debug for &'a T where
`impl<'a, T> Generator for &'a mut T where
`impl<'a, A, F> Fn for &'a F where
extern "rust-call" fn [call](../std/ops/trait.Fn.html#tymethod.call)(&self, args: A) -> <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
[src]
🔬 This is a nightly-only experimental API. (fn_traits
#29625)
Performs the call operation.
`impl<'a, T> Send for &'a mut T where
`impl<'a, T> Send for &'a T where
`impl<'a, W> Write for &'a mut W where
1.4.0
`impl<'a, I> TrustedLen for &'a mut I where
I: TrustedLen + ?Sized, `[src]
`impl<'a, T> UpperExp for &'a T where
`impl<'a, T> UpperExp for &'a mut T where
`impl<'a, T> UpperHex for &'a mut T where
`impl<'a, T> UpperHex for &'a T where
`impl<'a, T> Octal for &'a T where
`impl<'a, T> Octal for &'a mut T where
`impl<'a, T, U> CoerceUnsized<&'a mut U> for &'a mut T where
T: Unsize + ?Sized,
U: ?Sized, `[src]
`impl<'a, T, U> CoerceUnsized<*const U> for &'a T where
T: Unsize + ?Sized,
U: ?Sized, `[src]
`impl<'a, T, U> CoerceUnsized<*const U> for &'a mut T where
T: Unsize + ?Sized,
U: ?Sized, `[src]
`impl<'a, 'b, T, U> CoerceUnsized<&'a U> for &'b mut T where
'b: 'a,
T: Unsize + ?Sized,
U: ?Sized, `[src]
`impl<'a, T, U> CoerceUnsized<*mut U> for &'a mut T where
T: Unsize + ?Sized,
U: ?Sized, `[src]
`impl<'a, 'b, T, U> CoerceUnsized<&'a U> for &'b T where
'b: 'a,
T: Unsize + ?Sized,
U: ?Sized, `[src]
`impl<'a, I> DoubleEndedIterator for &'a mut I where
I: DoubleEndedIterator + ?Sized, `[src]
fn [next_back](../std/iter/trait.DoubleEndedIterator.html#tymethod.next%5Fback)(&mut self) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<<I as [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator")>::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")>
[src]
Removes and returns an element from the end of the iterator. Read more
`fn try_rfold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>, `[src]
🔬 This is a nightly-only experimental API. (iterator_try_fold
#45594)
This is the reverse version of [try_fold()
]: it takes elements starting from the back of the iterator. Read more
`fn rfold<B, F>(self, accum: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B, `[src]
🔬 This is a nightly-only experimental API. (iter_rfold
#44705)
An iterator method that reduces the iterator's elements to a single, final value, starting from the back. Read more
`fn rfind
(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool, `[src]
🔬 This is a nightly-only experimental API. (iter_rfind
#39480)
Searches for an element of an iterator from the right that satisfies a predicate. Read more
`impl<'a, H> Hasher for &'a mut H where
1.22.0
fn [finish](../std/hash/trait.Hasher.html#tymethod.finish)(&self) -> [u64](primitive.u64.html)
[src]
Returns the hash value for the values written so far. Read more
fn [write](../std/hash/trait.Hasher.html#tymethod.write)(&mut self, bytes: [&[](primitive.slice.html)[u8](primitive.u8.html)[]](primitive.slice.html))
[src]
Writes some data into this Hasher
. Read more
fn [write_u8](../std/hash/trait.Hasher.html#method.write%5Fu8)(&mut self, i: [u8](primitive.u8.html))
[src]
Writes a single u8
into this hasher.
fn [write_u16](../std/hash/trait.Hasher.html#method.write%5Fu16)(&mut self, i: [u16](primitive.u16.html))
[src]
Writes a single u16
into this hasher.
fn [write_u32](../std/hash/trait.Hasher.html#method.write%5Fu32)(&mut self, i: [u32](primitive.u32.html))
[src]
Writes a single u32
into this hasher.
fn [write_u64](../std/hash/trait.Hasher.html#method.write%5Fu64)(&mut self, i: [u64](primitive.u64.html))
[src]
Writes a single u64
into this hasher.
fn [write_u128](../std/hash/trait.Hasher.html#method.write%5Fu128)(&mut self, i: [u128](primitive.u128.html))
[src]
🔬 This is a nightly-only experimental API. (i128
#35118)
Writes a single u128
into this hasher.
fn [write_usize](../std/hash/trait.Hasher.html#method.write%5Fusize)(&mut self, i: [usize](primitive.usize.html))
[src]
Writes a single usize
into this hasher.
fn [write_i8](../std/hash/trait.Hasher.html#method.write%5Fi8)(&mut self, i: [i8](primitive.i8.html))
[src]
Writes a single i8
into this hasher.
fn [write_i16](../std/hash/trait.Hasher.html#method.write%5Fi16)(&mut self, i: [i16](primitive.i16.html))
[src]
Writes a single i16
into this hasher.
fn [write_i32](../std/hash/trait.Hasher.html#method.write%5Fi32)(&mut self, i: [i32](primitive.i32.html))
[src]
Writes a single i32
into this hasher.
fn [write_i64](../std/hash/trait.Hasher.html#method.write%5Fi64)(&mut self, i: [i64](primitive.i64.html))
[src]
Writes a single i64
into this hasher.
fn [write_i128](../std/hash/trait.Hasher.html#method.write%5Fi128)(&mut self, i: [i128](primitive.i128.html))
[src]
🔬 This is a nightly-only experimental API. (i128
#35118)
Writes a single i128
into this hasher.
fn [write_isize](../std/hash/trait.Hasher.html#method.write%5Fisize)(&mut self, i: [isize](primitive.isize.html))
[src]
Writes a single isize
into this hasher.
`impl<'a, T> Hash for &'a T where
`impl<'a, T> Hash for &'a mut T where
`impl<'a, T, U> AsMut for &'a mut T where
T: AsMut + ?Sized,
U: ?Sized, `[src]
`impl<'a, A, F> FnOnce for &'a F where
type [Output](../std/ops/trait.FnOnce.html#associatedtype.Output) = <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
The returned type after the call operator is used.
extern "rust-call" fn [call_once](../std/ops/trait.FnOnce.html#tymethod.call%5Fonce)(self, args: A) -> <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
[src]
🔬 This is a nightly-only experimental API. (fn_traits
#29625)
Performs the call operation.
`impl<'a, A, F> FnOnce for &'a mut F where
type [Output](../std/ops/trait.FnOnce.html#associatedtype.Output) = <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
The returned type after the call operator is used.
extern "rust-call" fn [call_once](../std/ops/trait.FnOnce.html#tymethod.call%5Fonce)(self, args: A) -> <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
[src]
🔬 This is a nightly-only experimental API. (fn_traits
#29625)
Performs the call operation.
`impl<'a, T> DerefMut for &'a mut T where
`impl<'a, I> FusedIterator for &'a mut I where
I: FusedIterator + ?Sized, `[src]
`impl<'a, 'b, A, B> PartialOrd<&'b mut B> for &'a mut A where
A: PartialOrd + ?Sized,
B: ?Sized, `[src]
`impl<'a, 'b, A, B> PartialOrd<&'b B> for &'a A where
A: PartialOrd + ?Sized,
B: ?Sized, `[src]
fn [partial_cmp](../std/cmp/trait.PartialOrd.html#tymethod.partial%5Fcmp)(&self, other: &[&'b ](primitive.reference.html)B) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<[Ordering](../std/cmp/enum.Ordering.html "enum std::cmp::Ordering")>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn [lt](../std/cmp/trait.PartialOrd.html#method.lt)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn [le](../std/cmp/trait.PartialOrd.html#method.le)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn [ge](../std/cmp/trait.PartialOrd.html#method.ge)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
fn [gt](../std/cmp/trait.PartialOrd.html#method.gt)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
`impl<'a, T> Deref for &'a mut T where
type [Target](../std/ops/trait.Deref.html#associatedtype.Target) = T
The resulting type after dereferencing.
fn [deref](../std/ops/trait.Deref.html#tymethod.deref)(&self) -> [&](primitive.reference.html)T
[src]
Dereferences the value.
`impl<'a, T> Deref for &'a T where
type [Target](../std/ops/trait.Deref.html#associatedtype.Target) = T
The resulting type after dereferencing.
fn [deref](../std/ops/trait.Deref.html#tymethod.deref)(&self) -> [&](primitive.reference.html)T
[src]
Dereferences the value.
`impl<'a, A> Ord for &'a A where
fn [cmp](../std/cmp/trait.Ord.html#tymethod.cmp)(&self, other: &[&'a ](primitive.reference.html)A) -> [Ordering](../std/cmp/enum.Ordering.html "enum std::cmp::Ordering")
[src]
This method returns an Ordering
between self
and other
. Read more
fn [max](../std/cmp/trait.Ord.html#method.max)(self, other: Self) -> Self
1.21.0
Compares and returns the maximum of two values. Read more
fn [min](../std/cmp/trait.Ord.html#method.min)(self, other: Self) -> Self
1.21.0
Compares and returns the minimum of two values. Read more
`impl<'a, A> Ord for &'a mut A where
`impl<'a, T> BorrowMut for &'a mut T where
`impl<'a, T> LowerExp for &'a mut T where
`impl<'a, T> LowerExp for &'a T where
`impl<'a, T> LowerHex for &'a T where
`impl<'a, T> LowerHex for &'a mut T where
`impl<'a, T> Display for &'a mut T where
`impl<'a, T> Display for &'a T where
`impl<'a, A> Eq for &'a mut A where
`impl<'a, A> Eq for &'a A where
`impl<'a, I> ExactSizeIterator for &'a mut I where
I: ExactSizeIterator + ?Sized, `[src]
`impl<'a, I> Iterator for &'a mut I where
type [Item](../std/iter/trait.Iterator.html#associatedtype.Item) = <I as [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator")>::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")
The type of the elements being iterated over.
fn [next](../std/iter/trait.Iterator.html#tymethod.next)(&mut self) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<<I as [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator")>::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")>
[src]
Advances the iterator and returns the next value. Read more
fn [size_hint](../std/iter/trait.Iterator.html#method.size%5Fhint)(&self) -> [(](primitive.tuple.html)[usize](primitive.usize.html), [Option](../std/option/enum.Option.html "enum std::option::Option")<[usize](primitive.usize.html)>[)](primitive.tuple.html)
[src]
Returns the bounds on the remaining length of the iterator. Read more
fn [nth](../std/iter/trait.Iterator.html#method.nth)(&mut self, n: [usize](primitive.usize.html)) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<<[&'a mut ](primitive.reference.html)I as [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator")>::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")>
[src]
Returns the n
th element of the iterator. Read more
fn [count](../std/iter/trait.Iterator.html#method.count)(self) -> [usize](primitive.usize.html)
[src]
Consumes the iterator, counting the number of iterations and returning it. Read more
fn [last](../std/iter/trait.Iterator.html#method.last)(self) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")>
[src]
Consumes the iterator, returning the last element. Read more
ⓘImportant traits for StepBy
fn [step_by](../std/iter/trait.Iterator.html#method.step%5Fby)(self, step: [usize](primitive.usize.html)) -> [StepBy](../std/iter/struct.StepBy.html "struct std::iter::StepBy")<Self>
[src]
🔬 This is a nightly-only experimental API. (iterator_step_by
#27741)
unstable replacement of Range::step_by
Creates an iterator starting at the same point, but stepping by the given amount at each iteration. Read more
ⓘImportant traits for Chain<A, B>
fn [chain](../std/iter/trait.Iterator.html#method.chain)<U>(self, other: U) -> [Chain](../std/iter/struct.Chain.html "struct std::iter::Chain")<Self, <U as [IntoIterator](../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator")>::[IntoIter](../std/iter/trait.IntoIterator.html#associatedtype.IntoIter "type std::iter::IntoIterator::IntoIter")> where U: [IntoIterator](../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator")<Item = Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")>,
[src]
Takes two iterators and creates a new iterator over both in sequence. Read more
ⓘImportant traits for Zip<A, B>
fn [zip](../std/iter/trait.Iterator.html#method.zip)<U>(self, other: U) -> [Zip](../std/iter/struct.Zip.html "struct std::iter::Zip")<Self, <U as [IntoIterator](../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator")>::[IntoIter](../std/iter/trait.IntoIterator.html#associatedtype.IntoIter "type std::iter::IntoIterator::IntoIter")> where U: [IntoIterator](../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator"),
[src]
'Zips up' two iterators into a single iterator of pairs. Read more
ⓘImportant traits for Map<I, F>
fn [map](../std/iter/trait.Iterator.html#method.map)<B, F>(self, f: F) -> [Map](../std/iter/struct.Map.html "struct std::iter::Map")<Self, F> where F: [FnMut](../std/ops/trait.FnMut.html "trait std::ops::FnMut")(Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> B,
[src]
Takes a closure and creates an iterator which calls that closure on each element. Read more
`fn for_each(self, f: F) where
1.21.0
Calls a closure on each element of an iterator. Read more
ⓘImportant traits for Filter<I, P>
fn [filter](../std/iter/trait.Iterator.html#method.filter)<P>(self, predicate: P) -> [Filter](../std/iter/struct.Filter.html "struct std::iter::Filter")<Self, P> where P: [FnMut](../std/ops/trait.FnMut.html "trait std::ops::FnMut")(&Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> [bool](primitive.bool.html),
[src]
Creates an iterator which uses a closure to determine if an element should be yielded. Read more
`fn filter_map<B, F>(self, f: F) -> FilterMap<Self, F> where
F: FnMut(Self::Item) -> Option, `[src]
Creates an iterator that both filters and maps. Read more
fn [enumerate](../std/iter/trait.Iterator.html#method.enumerate)(self) -> [Enumerate](../std/iter/struct.Enumerate.html "struct std::iter::Enumerate")<Self>
[src]
Creates an iterator which gives the current iteration count as well as the next value. Read more
fn [peekable](../std/iter/trait.Iterator.html#method.peekable)(self) -> [Peekable](../std/iter/struct.Peekable.html "struct std::iter::Peekable")<Self>
[src]
Creates an iterator which can use peek
to look at the next element of the iterator without consuming it. Read more
`fn skip_while
(self, predicate: P) -> SkipWhile<Self, P> where
P: FnMut(&Self::Item) -> bool, `[src]
Creates an iterator that [skip
]s elements based on a predicate. Read more
`fn take_while
(self, predicate: P) -> TakeWhile<Self, P> where
P: FnMut(&Self::Item) -> bool, `[src]
Creates an iterator that yields elements based on a predicate. Read more
ⓘImportant traits for Skip
fn [skip](../std/iter/trait.Iterator.html#method.skip)(self, n: [usize](primitive.usize.html)) -> [Skip](../std/iter/struct.Skip.html "struct std::iter::Skip")<Self>
[src]
Creates an iterator that skips the first n
elements. Read more
ⓘImportant traits for Take
fn [take](../std/iter/trait.Iterator.html#method.take)(self, n: [usize](primitive.usize.html)) -> [Take](../std/iter/struct.Take.html "struct std::iter::Take")<Self>
[src]
Creates an iterator that yields its first n
elements. Read more
ⓘImportant traits for Scan<I, St, F>
Important traits for Scan<I, St, F>
impl<B, I, St, F> [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator") for [Scan](../std/iter/struct.Scan.html "struct std::iter::Scan")<I, St, F> where F: [FnMut](../std/ops/trait.FnMut.html "trait std::ops::FnMut")([&mut ](primitive.reference.html)St, <I as [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator")>::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<B>, I: [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator"), type [Item](../std/iter/trait.Iterator.html#associatedtype.Item) = B;
fn [scan](../std/iter/trait.Iterator.html#method.scan)<St, B, F>(self, initial_state: St, f: F) -> [Scan](../std/iter/struct.Scan.html "struct std::iter::Scan")<Self, St, F> where F: [FnMut](../std/ops/trait.FnMut.html "trait std::ops::FnMut")([&mut ](primitive.reference.html)St, Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> [Option](../std/option/enum.Option.html "enum std::option::Option")<B>,
[src]
An iterator adaptor similar to [fold
] that holds internal state and produces a new iterator. Read more
ⓘImportant traits for FlatMap<I, U, F>
fn [flat_map](../std/iter/trait.Iterator.html#method.flat%5Fmap)<U, F>(self, f: F) -> [FlatMap](../std/iter/struct.FlatMap.html "struct std::iter::FlatMap")<Self, U, F> where F: [FnMut](../std/ops/trait.FnMut.html "trait std::ops::FnMut")(Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")) -> U, U: [IntoIterator](../std/iter/trait.IntoIterator.html "trait std::iter::IntoIterator"),
[src]
Creates an iterator that works like map, but flattens nested structure. Read more
ⓘImportant traits for Fuse
fn [fuse](../std/iter/trait.Iterator.html#method.fuse)(self) -> [Fuse](../std/iter/struct.Fuse.html "struct std::iter::Fuse")<Self>
[src]
Creates an iterator which ends after the first [None
]. Read more
ⓘImportant traits for Inspect<I, F>
fn [inspect](../std/iter/trait.Iterator.html#method.inspect)<F>(self, f: F) -> [Inspect](../std/iter/struct.Inspect.html "struct std::iter::Inspect")<Self, F> where F: [FnMut](../std/ops/trait.FnMut.html "trait std::ops::FnMut")(&Self::[Item](../std/iter/trait.Iterator.html#associatedtype.Item "type std::iter::Iterator::Item")),
[src]
Do something with each element of an iterator, passing the value on. Read more
fn [by_ref](../std/iter/trait.Iterator.html#method.by%5Fref)(&mut self) -> [&mut ](primitive.reference.html)Self
[src]
Borrows an iterator, rather than consuming it. Read more
`fn collect(self) -> B where
B: FromIterator<Self::Item>, `[src]
Transforms an iterator into a collection. Read more
`fn partition<B, F>(self, f: F) -> (B, B) where
B: Default + Extend<Self::Item>,
F: FnMut(&Self::Item) -> bool, `[src]
Consumes an iterator, creating two collections from it. Read more
`fn try_fold<B, F, R>(&mut self, init: B, f: F) -> R where
F: FnMut(B, Self::Item) -> R,
R: Try<Ok = B>, `[src]
🔬 This is a nightly-only experimental API. (iterator_try_fold
#45594)
An iterator method that applies a function as long as it returns successfully, producing a single, final value. Read more
`fn fold<B, F>(self, init: B, f: F) -> B where
F: FnMut(B, Self::Item) -> B, `[src]
An iterator method that applies a function, producing a single, final value. Read more
`fn all(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool, `[src]
Tests if every element of the iterator matches a predicate. Read more
`fn any(&mut self, f: F) -> bool where
F: FnMut(Self::Item) -> bool, `[src]
Tests if any element of the iterator matches a predicate. Read more
`fn find
(&mut self, predicate: P) -> Option<Self::Item> where
P: FnMut(&Self::Item) -> bool, `[src]
Searches for an element of an iterator that satisfies a predicate. Read more
`fn position
(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool, `[src]
Searches for an element in an iterator, returning its index. Read more
`fn rposition
(&mut self, predicate: P) -> Option<usize> where
P: FnMut(Self::Item) -> bool,
Self: ExactSizeIterator + DoubleEndedIterator, `[src]
Searches for an element in an iterator from the right, returning its index. Read more
`fn max(self) -> Option<Self::Item> where
Returns the maximum element of an iterator. Read more
`fn min(self) -> Option<Self::Item> where
Returns the minimum element of an iterator. Read more
`fn max_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B, `
1.6.0
Returns the element that gives the maximum value from the specified function. Read more
`fn max_by(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering, `
1.15.0
Returns the element that gives the maximum value with respect to the specified comparison function. Read more
`fn min_by_key<B, F>(self, f: F) -> Option<Self::Item> where
B: Ord,
F: FnMut(&Self::Item) -> B, `
1.6.0
Returns the element that gives the minimum value from the specified function. Read more
`fn min_by(self, compare: F) -> Option<Self::Item> where
F: FnMut(&Self::Item, &Self::Item) -> Ordering, `
1.15.0
Returns the element that gives the minimum value with respect to the specified comparison function. Read more
ⓘImportant traits for Rev
fn [rev](../std/iter/trait.Iterator.html#method.rev)(self) -> [Rev](../std/iter/struct.Rev.html "struct std::iter::Rev")<Self> where Self: [DoubleEndedIterator](../std/iter/trait.DoubleEndedIterator.html "trait std::iter::DoubleEndedIterator"),
[src]
Reverses an iterator's direction. Read more
`fn unzip<A, B, FromA, FromB>(self) -> (FromA, FromB) where
FromA: Default + Extend,
FromB: Default + Extend,
Self: Iterator<Item = (A, B)>, `[src]
Converts an iterator of pairs into a pair of containers. Read more
ⓘImportant traits for Cloned
fn [cloned](../std/iter/trait.Iterator.html#method.cloned)<'a, T>(self) -> [Cloned](../std/iter/struct.Cloned.html "struct std::iter::Cloned")<Self> where Self: [Iterator](../std/iter/trait.Iterator.html "trait std::iter::Iterator")<Item = [&'a ](primitive.reference.html)T>, T: 'a + [Clone](../std/clone/trait.Clone.html "trait std::clone::Clone"),
[src]
Creates an iterator which [clone
]s all of its elements. Read more
ⓘImportant traits for Cycle
fn [cycle](../std/iter/trait.Iterator.html#method.cycle)(self) -> [Cycle](../std/iter/struct.Cycle.html "struct std::iter::Cycle")<Self> where Self: [Clone](../std/clone/trait.Clone.html "trait std::clone::Clone"),
[src]
Repeats an iterator endlessly. Read more
`fn sum(self) -> S where
1.11.0
Sums the elements of an iterator. Read more
`fn product
(self) -> P where
1.11.0
Iterates over the entire iterator, multiplying all the elements Read more
`fn cmp(self, other: I) -> Ordering where
I: IntoIterator<Item = Self::Item>,
Self::Item: Ord, `
1.5.0
Lexicographically compares the elements of this Iterator
with those of another. Read more
`fn partial_cmp(self, other: I) -> Option<Ordering> where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `
1.5.0
Lexicographically compares the elements of this Iterator
with those of another. Read more
`fn eq(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>, `
1.5.0
Determines if the elements of this Iterator
are equal to those of another. Read more
`fn ne(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialEq<<I as IntoIterator>::Item>, `
1.5.0
Determines if the elements of this Iterator
are unequal to those of another. Read more
`fn lt(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `
1.5.0
Determines if the elements of this Iterator
are lexicographically less than those of another. Read more
`fn le(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `
1.5.0
Determines if the elements of this Iterator
are lexicographically less or equal to those of another. Read more
`fn gt(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `
1.5.0
Determines if the elements of this Iterator
are lexicographically greater than those of another. Read more
`fn ge(self, other: I) -> bool where
I: IntoIterator,
Self::Item: PartialOrd<<I as IntoIterator>::Item>, `
1.5.0
Determines if the elements of this Iterator
are lexicographically greater than or equal to those of another. Read more
`impl<'a, 'b, A, B> PartialEq<&'b B> for &'a A where
A: PartialEq + ?Sized,
B: ?Sized, `[src]
fn [eq](../std/cmp/trait.PartialEq.html#tymethod.eq)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn [ne](../std/cmp/trait.PartialEq.html#method.ne)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests for !=
.
`impl<'a, 'b, A, B> PartialEq<&'b B> for &'a mut A where
A: PartialEq + ?Sized,
B: ?Sized, `[src]
fn [eq](../std/cmp/trait.PartialEq.html#tymethod.eq)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn [ne](../std/cmp/trait.PartialEq.html#method.ne)(&self, other: &[&'b ](primitive.reference.html)B) -> [bool](primitive.bool.html)
[src]
This method tests for !=
.
`impl<'a, 'b, A, B> PartialEq<&'b mut B> for &'a mut A where
A: PartialEq + ?Sized,
B: ?Sized, `[src]
`impl<'a, 'b, A, B> PartialEq<&'b mut B> for &'a A where
A: PartialEq + ?Sized,
B: ?Sized, `[src]
`impl<'a, T, U> AsRef for &'a T where
T: AsRef + ?Sized,
U: ?Sized, `[src]
`impl<'a, T, U> AsRef for &'a mut T where
T: AsRef + ?Sized,
U: ?Sized, `[src]
`impl<'a, A, F> FnMut for &'a F where
extern "rust-call" fn [call_mut](../std/ops/trait.FnMut.html#tymethod.call%5Fmut)(&mut self, args: A) -> <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
[src]
🔬 This is a nightly-only experimental API. (fn_traits
#29625)
Performs the call operation.
`impl<'a, A, F> FnMut for &'a mut F where
extern "rust-call" fn [call_mut](../std/ops/trait.FnMut.html#tymethod.call%5Fmut)(&mut self, args: A) -> <F as [FnOnce](../std/ops/trait.FnOnce.html "trait std::ops::FnOnce")<A>>::[Output](../std/ops/trait.FnOnce.html#associatedtype.Output "type std::ops::FnOnce::Output")
[src]
🔬 This is a nightly-only experimental API. (fn_traits
#29625)
Performs the call operation.
`impl<'a, T> Borrow for &'a T where
`impl<'a, T> Borrow for &'a mut T where
impl<'a, R: [Read](../std/io/trait.Read.html "trait std::io::Read") + ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")> [Read](../std/io/trait.Read.html "trait std::io::Read") for [&'a mut ](primitive.reference.html)R
[src]
fn [read](../std/io/trait.Read.html#tymethod.read)(&mut self, buf: [&mut [](primitive.slice.html)[u8](primitive.u8.html)[]](primitive.slice.html)) -> [Result](../std/io/type.Result.html "type std::io::Result")<[usize](primitive.usize.html)>
[src]
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
unsafe fn [initializer](../std/io/trait.Read.html#method.initializer)(&self) -> [Initializer](../std/io/struct.Initializer.html "struct std::io::Initializer")
[src]
🔬 This is a nightly-only experimental API. (read_initializer
#42788)
Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn [read_to_end](../std/io/trait.Read.html#method.read%5Fto%5Fend)(&mut self, buf: &mut [Vec](../std/vec/struct.Vec.html "struct std::vec::Vec")<[u8](primitive.u8.html)>) -> [Result](../std/io/type.Result.html "type std::io::Result")<[usize](primitive.usize.html)>
[src]
Read all bytes until EOF in this source, placing them into buf
. Read more
fn [read_to_string](../std/io/trait.Read.html#method.read%5Fto%5Fstring)(&mut self, buf: &mut [String](../std/string/struct.String.html "struct std:🧵:String")) -> [Result](../std/io/type.Result.html "type std::io::Result")<[usize](primitive.usize.html)>
[src]
Read all bytes until EOF in this source, appending them to buf
. Read more
fn [read_exact](../std/io/trait.Read.html#method.read%5Fexact)(&mut self, buf: [&mut [](primitive.slice.html)[u8](primitive.u8.html)[]](primitive.slice.html)) -> [Result](../std/io/type.Result.html "type std::io::Result")<[()](primitive.unit.html)>
[src]
Read the exact number of bytes required to fill buf
. Read more
`fn by_ref(&mut self) -> &mut Self where
Creates a "by reference" adaptor for this instance of Read
. Read more
ⓘImportant traits for Bytes
fn [bytes](../std/io/trait.Read.html#method.bytes)(self) -> [Bytes](../std/io/struct.Bytes.html "struct std::io::Bytes")<Self> where Self: [Sized](../std/marker/trait.Sized.html "trait std:📑:Sized"),
[src]
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
ⓘImportant traits for Chars
fn [chars](../std/io/trait.Read.html#method.chars)(self) -> [Chars](../std/io/struct.Chars.html "struct std::io::Chars")<Self> where Self: [Sized](../std/marker/trait.Sized.html "trait std:📑:Sized"),
[src]
🔬 This is a nightly-only experimental API. (io
#27802)
the semantics of a partial read/write of where errors happen is currently unclear and may change
Transforms this Read
instance to an [Iterator
] over [char
]s. Read more
ⓘImportant traits for Chain<T, U>
fn [chain](../std/io/trait.Read.html#method.chain)<R: [Read](../std/io/trait.Read.html "trait std::io::Read")>(self, next: R) -> [Chain](../std/io/struct.Chain.html "struct std::io::Chain")<Self, R> where Self: [Sized](../std/marker/trait.Sized.html "trait std:📑:Sized"),
[src]
Creates an adaptor which will chain this stream with another. Read more
ⓘImportant traits for Take
fn [take](../std/io/trait.Read.html#method.take)(self, limit: [u64](primitive.u64.html)) -> [Take](../std/io/struct.Take.html "struct std::io::Take")<Self> where Self: [Sized](../std/marker/trait.Sized.html "trait std:📑:Sized"),
[src]
Creates an adaptor which will read at most limit
bytes from it. Read more
impl<'a, W: [Write](../std/io/trait.Write.html "trait std::io::Write") + ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")> [Write](../std/io/trait.Write.html "trait std::io::Write") for [&'a mut ](primitive.reference.html)W
[src]
impl<'a, S: [Seek](../std/io/trait.Seek.html "trait std::io::Seek") + ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")> [Seek](../std/io/trait.Seek.html "trait std::io::Seek") for [&'a mut ](primitive.reference.html)S
[src]
impl<'a, B: [BufRead](../std/io/trait.BufRead.html "trait std::io::BufRead") + ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")> [BufRead](../std/io/trait.BufRead.html "trait std::io::BufRead") for [&'a mut ](primitive.reference.html)B
[src]
fn [fill_buf](../std/io/trait.BufRead.html#tymethod.fill%5Fbuf)(&mut self) -> [Result](../std/io/type.Result.html "type std::io::Result")<[&[](primitive.slice.html)[u8](primitive.u8.html)[]](primitive.slice.html)>
[src]
Fills the internal buffer of this object, returning the buffer contents. Read more
fn [consume](../std/io/trait.BufRead.html#tymethod.consume)(&mut self, amt: [usize](primitive.usize.html))
[src]
Tells this buffer that amt
bytes have been consumed from the buffer, so they should no longer be returned in calls to read
. Read more
fn [read_until](../std/io/trait.BufRead.html#method.read%5Funtil)(&mut self, byte: [u8](primitive.u8.html), buf: &mut [Vec](../std/vec/struct.Vec.html "struct std::vec::Vec")<[u8](primitive.u8.html)>) -> [Result](../std/io/type.Result.html "type std::io::Result")<[usize](primitive.usize.html)>
[src]
Read all bytes into buf
until the delimiter byte
or EOF is reached. Read more
fn [read_line](../std/io/trait.BufRead.html#method.read%5Fline)(&mut self, buf: &mut [String](../std/string/struct.String.html "struct std:🧵:String")) -> [Result](../std/io/type.Result.html "type std::io::Result")<[usize](primitive.usize.html)>
[src]
Read all bytes until a newline (the 0xA byte) is reached, and append them to the provided buffer. Read more
ⓘImportant traits for Split
fn [split](../std/io/trait.BufRead.html#method.split)(self, byte: [u8](primitive.u8.html)) -> [Split](../std/io/struct.Split.html "struct std::io::Split")<Self> where Self: [Sized](../std/marker/trait.Sized.html "trait std:📑:Sized"),
[src]
Returns an iterator over the contents of this reader split on the byte byte
. Read more
ⓘImportant traits for Lines
fn [lines](../std/io/trait.BufRead.html#method.lines)(self) -> [Lines](../std/io/struct.Lines.html "struct std::io::Lines")<Self> where Self: [Sized](../std/marker/trait.Sized.html "trait std:📑:Sized"),
[src]
Returns an iterator over the lines of this reader. Read more
impl<'a, T: [ToSocketAddrs](../std/net/trait.ToSocketAddrs.html "trait std:🥅:ToSocketAddrs") + ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")> [ToSocketAddrs](../std/net/trait.ToSocketAddrs.html "trait std:🥅:ToSocketAddrs") for [&'a ](primitive.reference.html)T
[src]
impl<'a, T: ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")>  for [&'a mut ](primitive.reference.html)T
1.9.0
impl<'a, T: [RefUnwindSafe](../std/panic/trait.RefUnwindSafe.html "trait std::panic::RefUnwindSafe") + ?[Sized](../std/marker/trait.Sized.html "trait std:📑:Sized")> [UnwindSafe](../std/panic/trait.UnwindSafe.html "trait std::panic::UnwindSafe") for [&'a ](primitive.reference.html)T
1.9.0