将 rust 标准库中的几个常用类型的方法安装第一个入参(即:Move、借用、可变借用)分组整理,以便开发时做个参考。
Type | (..) | (self..) | (&self..) | (&mut self..) |
---|---|---|---|---|
Cow | from() | into_owned() | to_mut() | |
Cell | from() from_mut() new() | into_inner() | set() get() take() replace() | get_mut() |
RefCell | from() new() | into_inner() | borrow() borrow_mut() take() replace() | get_mut() |
Vec | from() new() with_capacity() | into_boxed_slice() | len() capacity() is_empyt() | insert() append() push() pop() remove() drain() clear() splice() reserve() resize() shrink_to() truncate() |
BTreeMap | from() new() | into_keys() range() | get() len() keys() values() iter() get_key_value() first_key_value() last_key_value() contains_key() is_empyt() | insert() append() extend retain() remove() pop_first() pop_last() entry() first_entry() last_entry() |
HashMap | from() new() | keys() into_keys() capacity() | get() len() values() iter() is_empty() | insert() extend retain() drain() remove() remove_entry() reserve() entry() |
Box | from() new() leak() pin() | downcast() split() | borrow() | borrow_mut() consume() read_line() |