Frequently used methods

Doosan published on
4 min, 687 words

Categories: Post

A collection of functions frequently used when solving leetcode problems with Rust

std

Struct String in std::string module

push
push_str
and all the methods listed below in str

Struct Vec in std::vec module

push
pop
slice
insert
remove
splice
dedup
and all the methods listed below in slice

Primitive Type str

as_bytes
bytes
chars
len

Primitive Type Slice

contains
concat
join
first
last
get
len
iter
iter_mut
split
rsplit
sort
sort_by
reverse
windows
to_vec
*into_vec

std::collections

Struct VecDeque

push_back
pop_back
back
back_mut
push_front
pop_front
front
front_mut
insert
get
remove
append

Struct HashMap

entry

and_motify
insert_entry
or_insert

insert
get
keys
values
iter
len

Struct HashSet

insert
get
get_or_insert
remove
take
iter
len

std::iter

Trait Iterator

collect
collect_into
flatten
fold
map
max
max_by
min
min_by
nth
reduce && fold
rev
skip
take
zip