diff options
| author | Tyge Løvset <[email protected]> | 2022-03-16 21:41:40 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2022-03-16 21:41:40 +0100 |
| commit | 0468971b404cee5582d360d7d1c66bb4148e1614 (patch) | |
| tree | 9161ccbea490a5dab70e641f7bd568521a5da636 /examples/utf8replace_rs.rs | |
| parent | 342484f70998258022c26e6af2926ecc7635bbdd (diff) | |
| download | STC-modified-0468971b404cee5582d360d7d1c66bb4148e1614.tar.gz STC-modified-0468971b404cee5582d360d7d1c66bb4148e1614.zip | |
Bugfix: carc and cbox cmp functions had bug.
Renamed: i_key_sptr / i_val_sptr to i_key_arcbox / i_val_arcbox.
Other smaller updates.
Diffstat (limited to 'examples/utf8replace_rs.rs')
| -rw-r--r-- | examples/utf8replace_rs.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/examples/utf8replace_rs.rs b/examples/utf8replace_rs.rs new file mode 100644 index 00000000..717978aa --- /dev/null +++ b/examples/utf8replace_rs.rs @@ -0,0 +1,19 @@ + +pub fn main() { + let mut hello = String::from("hell😀 world"); + println!("{}", hello); + + hello.replace_range( + hello + .char_indices() + .nth(4) + .map(|(pos, ch)| (pos..pos + ch.len_utf8())) + .unwrap(), + "🐨", + ); + println!("{}", hello); + + for c in hello.chars() { + print!("{},", c); + } +} |
