Last active
November 17, 2024 18:09
-
-
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/f57022ffcd6ed188944532caa437500c0e161a89
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 NON-AI License Version 2.0 (https://raw.githubusercontent.com/non-ai-licenses/non-ai-licenses/main/NON-AI-APACHE2) | |
// 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