Sunteți pe pagina 1din 2

7/8/2019 Basics - Rust cheat sheet

Option<T> Iterator<Item = T> &[T] &[u8]


To inner type Mapping and filtering Splitting to iterator ASCII
unwrap () T map (( T) U) Iterator<Item = U> split ((&T) bool) Iterator<Item = &[T]> is_ascii ()
unwrap_or (T) T filter ((&T) bool) Iterator<Item = T> rsplit ((&T) bool) Iterator<Item = &[T]> eq_ignore_asc
unwrap_or_else (() T) T filter_map (( T) Option<U>) Iterator<Item = U> splitn (usize, (&T) bool) Iterator<Item = &[T]> to_ascii_uppe
unwrap_or_default () T where T Default rsplitn (usize, (&T) bool) Iterator<Item = &[T]> to_ascii_lowe
expect (&str) T Collecting and folding
fold (S, (S, T) S) S Splitting at position
Converting to another type collect () B where B FromIterator<T> split_at (usize) (&[T], &[T]) &mut [u8
map ((T) U) Option<U> partition ((&T) bool) (B, B) where B Default + Extend<T> split_first () Option<(&T, &[T])>
ASCII
map_or (U, (T) U) U split_last () Option<(&T, &[T])>
Counting and enumerating make_ascii_up
map_or_else (() U, (T) U) U
count () usize Chunks and windows make_ascii_lo
To Result last () Option<T> chunks (usize) Iterator<Item = &[T]>
ok_or (E) Result<T, E>
ok_or_else (() E) Result<T, E>
enumerate () Iterator<Item = (usize, T)> chunks_exact (usize)
rchunks (usize)
Iterator<Item
Iterator<Item
=
=
&[T]>
&[T]>
str
Combining with other iterators rchunks_exact (usize) Iterator<Item = &[T]> Bytes
Conditioning zip (IntoIterator<Item = U>) Iterator<Item = (T, U)> windows (usize) Iterator<Item = &[T]> from_utf8
filter ((&T) bool) Option<T> chain (IntoIterator<Item = T>) Iterator<Item = T>
from_utf8_mut
and (Option<U>) Option<U> Matching
and_then ((T) Option<U>) Option<U> Flattening contains (&T) bool where T PartialEq
or (Option<T>) Option<T> flatten ()
flat_map ((T)
Iterator<U> where T IntoIterator<U>
IntoIterator<Item = U>) Iterator<Item = U>
starts_with (&[T]) bool where T PartialEq &str
or_else (() Option<T>) Option<T> ends_with (&[T]) bool where T PartialEq
Chars
Taking and skipping Binary searching chars () I
Option<&T> skip (usize) Iterator<Item = T> binary_search (&T) Result<usize, usize> where T Ord char_indices
take (usize) Iterator<Item = T> binary_search_by ((&T) Ordering) Result<usize, usize> is_char_bound
Cloning inner skip_while ((&T) bool) Iterator<Item = T> binary_search_by_key (&B, (&T) B) Result<usize, usize> where B Ord
cloned () Option<T> where T Clone take_while ((&T) bool) Iterator<Item = T> Bytes
copied () Option<T> where T Copy step_by (usize) Iterator<Item = T> Getting and iterating bytes () I
first () Option<&T> as_bytes ()
Misc. iterating
Option<Result<T, E for_each ((T) ()) ()
last () Option<&T>
get (SliceIndex<[T]>) Option<&T> Splitting to
inspect ((&T) ()) Iterator<Item = T> iter () Iterator<Item = &T> split_at (usi
Transposing
scan (S, (&mut S, T) Option<U>) Iterator<Item = U>
transpose () Result<Option<T>, E> Splitting to
Length
Calculations len () usize lines () I
&Option<T> sum ()
product ()
S where S
P where P
Sum<T>
Product<T>
is_empty () bool split_whitesp
split_ascii_w
Checking inner split (Patte
is_some () bool
Maximum and minimum &mut [T] rsplit (Patte
max () Option<T> where T Ord
is_none () bool splitn (usiz
min () Option<T> where T Ord Splitting to iterator
rsplitn (usiz
To inner reference max_by ((&T, &T) Ordering) Option<T> split_mut ((&T) bool) Iterator<Item = &mut [T]>
split_termina
as_ref () Option<&T> min_by ((&T, &T) Ordering) Option<T> rsplit_mut ((&T) bool) Iterator<Item = &mut [T]>
rsplit_termin
iter () Iterator<&T> max_by_key ((&T) U) Option<T> where U Ord splitn_mut (usize, (&T) bool) Iterator<Item = &mut [T]>
min_by_key ((&T) U) Option<T> where U Ord rsplitn_mut (usize, (&T) bool) Iterator<Item = &mut [T]> Trimming

&mut Option<T> Comparing with another iterator Splitting at position


trim (
trim_start (
eq (IntoIterator<Item = T>) bool where T PartialEq split_at_mut (usize) (&mut [T], &mut [T])
To inner mutable reference trim_end (
ne (IntoIterator<Item = T>) bool where T PartialEq split_first_mut () Option<(&mut T, &mut [T])>
as_mut () Option<&mut T> trim_matches
lt (IntoIterator<Item = T>) bool where T PartialOrd split_last_mut () Option<(&mut T, &mut [T])>
iter_mut () Iterator<&mut T> trim_start_ma
le (IntoIterator<Item = T>) bool where T PartialOrd
Chunks trim_end_matc
gt (IntoIterator<Item = T>) bool where T PartialOrd
Mutation chunks_mut (usize) Iterator<Item = &mut [T]>
ge (IntoIterator<Item = T>) bool where T PartialOrd Matching and
take () Option<T> chunks_exact_mut (usize) Iterator<Item = &mut [T]>
cmp (IntoIterator<Item = T>) Ordering where T Ord contains
replace (T) Option<T> rchunks_mut (usize) Iterator<Item = &mut [T]>
partial_cmp (IntoIterator<Item = T>) starts_with
get_or_insert (T) &mut T rchunks_exact_mut (usize) Iterator<Item = &mut [T]>
Option<Ordering> where T PartialOrd ends_with
get_or_insert_with (() T) &mut T
Sorting find (Patter
Reversing and cycling
rfind (Patter
Result<T, E> rev () Iterator<Item = T> where Self: DoubleEndedIterator
sort () where T Ord
sort_by ((&T, &T) Ordering) matches (Pat
cycle () Iterator<Item = T> where Self: Clone
To inner type
unwrap () T where E Debug
Iterator<Item = &T> sort_by_key ((&T) K) where K Ord
sort_by_cached_key ((&T) K) where K Ord
rmatches (Pat
match_indices
unwrap_err () E where T Debug Cloning inner sort_unstable () where T Ord rmatch_indice
unwrap_or (T) T cloned () Iterator<T> where T Clone sort_unstable_by ((&T, &T) Ordering)
Case
unwrap_or_else ((E) T) T sort_unstable_by_key ((&T) K) where K Ord
to_uppercase
unwrap_or_default () T where T Default
expect (&str) T &mut Iterator<Item = T> Rearranging to_lowercase
swap (usize, usize) to_ascii_uppe
expect_err (&str) E
Finding and positioning reverse () to_ascii_lowe
ok () Option<T>
find ((&T) bool) Option<T> rotate_left (usize) eq_ignore_asc
err () Option<E>
find_map (( T) Option<U>) Option<U> rotate_right (usize)
position (( T) bool) Option<usize> Replacing
Mapping
rposition (( T) bool) Option<usize> Overriding replace (Pat
map ((T) U) Result<U, E>
where Self: ExactSizeIterator + DoubleEndedIterator swap_with_slice (&mut [T]) replacen (Pat
map_err ((E) F) Result<T, F>
copy_from_slice (&[T]) where T Copy
Boolean operations Length
Conditioning clone_from_slice (&[T]) where T Clone
all ((T) bool) bool len () usi
and (Result<U, E>) Result<U, E>
any ((T) bool) bool Getting and iterating is_empty ()
and_then ((T) Result<U, E>) Result<U, E>
first_mut () Option<&mut T>
or (Result<T, F>) Result<T, F> Misc.
Try iterating last_mut () Option<&mut T>
or_else ((E) Result<T, F>) Result<T, F> is_ascii ()
try_for_each ((T) R) R where R Try<Ok = ()> get_mut (SliceIndex<[T]>) Option<&mut T>
try_fold (S, (S, T) R) R where R Try<Ok = S> iter_mut () Iterator<Item = &mut T> repeat (usize
Result<Option<T>, E> encode_utf16
parse () R
Transposing iter &mut Vec<T>
transpose () Option<Result<T, E
Creating simple iterators Adding and removing single item &mut str
empty () Iterator<Item = T> push (T)
&Result<T, E> once (T) Iterator<Item = T> pop () Option<T> Splitting to
repeat (T) Iterator<Item = T> where T Clone insert (usize, T) split_at_mut
Checking inner repeat_with (() T) Iterator<Item = T> remove (usize) T
is_ok () bool Case conversi
from_fn (() Option<T>) Iterator<Item = T> swap_remove (usize) T
is_err () bool make_ascii_up
successors (Option<T>, (&T) Option<T>) Iterator<Item = T>
Extending make_ascii_lo
To inner reference
append (&mut Vec<T>)
as_ref () Result<&T, &E>
iter () Iterator<Item = &T>
extend (IntoIterator<Item = T>) &mut Str
extend (IntoIterator<Item = &T>) where T Copy
extend_from_slice (&[T]) where T Clone Inserting and
&mut Result<T, E> Resizing
push_str (&st
insert_str (u
To inner mutable reference truncate (usize)
as_mut () Result<&mut T, &mut E> resize (usize, T) where T Clone Adding and re
iter_mut () Iterator<Item = &mut T> resize_with (usize, () T) push (char)
pop () Opt
Clearing insert (usize
clear () remove (usize
retain ((&T) bool)
Clearing
Removing or replacing range into iterator clear ()
drain (RangeBounds<usize>) Iterator<T> truncate (usi
splice (RangeBounds<usize>, IntoIterator<Item = T>) Iterator<T> retain ((char

Deduplicating Capacity mani


dedup () where T PartialEq reserve (usiz
dedup_by ((&mut T, &mut T) bool) reserve_exact
dedup_by_key ((&mut T) K) where K PartialEq shrink_to_fit

Splitting off Misc.


split_off (usize) Vec<T> split_off (us
replace_range
Capacity manipulation
drain (RangeB
reserve (usize)
reserve_exact (usize) Dark Single Large GitHub
shrink_to_fit ()

https://upsuper.github.io/rust-cheatsheet/ 1/2
7/8/2019 Basics - Rust cheat sheet

Dark Single Large GitHub

https://upsuper.github.io/rust-cheatsheet/ 2/2

S-ar putea să vă placă și