Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:22
Show Gist options
  • Select an option

  • Save dacr/91d55df27eff81453d8143b4b53b2737 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/91d55df27eff81453d8143b4b53b2737 to your computer and use it in GitHub Desktop.
hello rust strings / published by https://github.com/dacr/code-examples-manager #4c26c763-ab9d-4a12-a228-8d65e0eafde3/3ddceec320609ff5863c1b8471d8ec92ee357891
#!/usr/bin/env rust-script
// cargo-deps : trim-margin="0.1.0"
// summary : hello rust strings
// keywords : rust, strings, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : 4c26c763-ab9d-4a12-a228-8d65e0eafde3
// created-on : 2024-10-15T22:12:28+02:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : ./$file
use trim_margin::MarginTrimmable;
fn main() {
let str1 = "immutable string";
let str2 = String::from("mutable string");
println!("hello simple strings");
println!(r#"hello raw \nsimple strings"#);
println!("hello interpolated strings {str1} {str2}");
println!(r#"===============================
hello multiline strings (raw string)
which also support interpolations {str1}
==============================="#
);
let multi_with_margin ="
|-------------------------------
|hello multiline strings with stripped margins
|which also support interpolations {str1}
|-------------------------------".trim_margin().unwrap();
println!("{multi_with_margin}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment