rust-by-practice/en/src/compound-types/slice.md

10 lines
281 B
Markdown
Raw Normal View History

2022-02-26 23:01:40 -06:00
# slice todo
```rust,editable
// The trimmed string is a slice to the original string, hence no new
// allocation is performed
let chars_to_trim: &[char] = &[' ', ','];
let trimmed_str: &str = string.trim_matches(chars_to_trim);
println!("Used characters: {}", trimmed_str);
```