summaryrefslogtreecommitdiffhomepage
path: root/examples/utf8replace_rs.rs
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-03-16 21:41:40 +0100
committerTyge Løvset <[email protected]>2022-03-16 21:41:40 +0100
commit0468971b404cee5582d360d7d1c66bb4148e1614 (patch)
tree9161ccbea490a5dab70e641f7bd568521a5da636 /examples/utf8replace_rs.rs
parent342484f70998258022c26e6af2926ecc7635bbdd (diff)
downloadSTC-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.rs19
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);
+ }
+}