Rust's stdlib does not support index and access string with vec-like subscript syntax. Slicing string could also be "dangerous" for it will panic and crash if you achieve the middle of single utf-8 char.
"You should use ranges to create string slices with caution, because doing so can crash your program"
So I try to make this small and simple library to make things simpler and less tiring.
The library offers wrapper type IndexedString
based on vec witch supports indexing, iterating and modifying string.
And it can convert from and to string and string slice simply and safely like vec.
Simply add dependency to cargo.toml
```toml [dependencies]
indexed_string = "0.1.0" ```
```rust /// import mod to scope use indexedstring::indexedstring::IndexedString;
let str = "Stand with Ukraine";
/// convert &str to IndexedString let indexed_string = IndexedString::from(str);
/// immutably access string asserteq!(indexedstring[1], "t"); /// mutably access string indexed_string[0] = "s";
/// Get modified new string println!("{}", indexedstring.tostring);
```
As its description, it is just a naive implementation(I am not familiar with rust)
But it is tested and works :)
Feel free to fork it and open pull request for refactoring, bug fix and so on.
MIT for detail please visit the website