hyperion/20-dev/00-rust/20-dictionary/Untitled.md
2025-12-28 19:00:03 +03:00

44 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```rust
methods:
.to_lowercase()
.flat_map()
.par_iter()
.par_bridge()
.map()
.filter()
.fold()
.find()
.collect()
.copied()
.filter_map()
.windows()
.any()
.all()
.position()
.fetch_add()
.load()
.ends_with()
.enumerate()
.saturating_sub()
.try_fold()
.append() // по &mut ссылке
.extend() // ownership (removes obj in parantheses)
.flatten()
.then_some()
crates:
use memchr::memmem;
traits:
AsRef<str>
PartialEq
```
| Префикс | Что делает (Технический смысл) | Пример | Стоимость (Cost) |
| ------- | ----------------------------------------------------------------------------------- | -------------------- | ------------------------------------- |
| as_ | View / Borrow. Бесплатное преобразование типа, работающее с ссылкой. | as_bytes() | Нулевая (Zero-cost) |
| to_ | Clone / Allocate. Создает новую копию данных (тяжелая операция). | to_string(),to_vec() | Аллокация памяти |
| into_ | Consume. Потребляет (съедает) переменную. После этого старая переменная недоступна. | into_iter() | Обычно дешево (перемещение указателя) |