fn main() { println!("Hello, testing for crates.io!"); let ff = string_find_f("test for crates"); println!("find it : {}", ff); let cf = choose_str(1); println!("cf = {}", cf); } // char_indices() works for Rust chars (UTF-8) // if don't specify lifetime Rust trys assumptions // fn string_find_f(s: &str) -> &str { fn string_find_f<'a>(s: &'a str) -> &'a str { for (n, x) in s.char_indices() { if x == 'f' { return &s[n..]; } } s // return value if 'f' not found } // lifetime example - return &str - don't know lifetime fn choose_str(n: i32) -> &'static str { match n { 0 => "hello", 1 => "goodbye", _ => "other", } } // Changes to Cargo.toml to upload to crates.io // to change have to upload a new version // change version number to do that /* ======================== [package] name = "v1_hello_crates_demo_test_crate_do_not_use" version = "0.1.0" authors = ["david ellison "] edition = "2018" keywords = ["do", "not", "use"] repository = xxxxxxxxxxxxxxx source repository description = "Do not use this crate for demo only" readme = "readme.md" ======== The repository field should be a URL to the source repository for your package. repository = "https://github.com/rust-lang/cargo/" */