Skip to content

Instantly share code, notes, and snippets.

@raffylopez
Created July 12, 2017 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raffylopez/9759bfc82d1fd3ab422048686c0106c9 to your computer and use it in GitHub Desktop.
Save raffylopez/9759bfc82d1fd3ab422048686c0106c9 to your computer and use it in GitHub Desktop.
A Slice of Rusty Pi!
// no-shebang
#![allow(unused_imports)]
#![allow(dead_code)]
#![allow(unused_variables,unused_must_use)]
#![allow(unused_mut)]
// -- in rust, a slice of a String is an &str ref
fn main() {
let pi = "3.14151".to_string();
let slice_of_pi: &str = &pi[0..3];
println!("slice_of_pi -> {}", slice_of_pi);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment