Move tons of stuff into oldstuff/

This commit is contained in:
2020-06-04 09:54:59 -04:00
parent 49038bb8ef
commit aa1345b6ed
213 changed files with 0 additions and 12 deletions

View File

@@ -0,0 +1,6 @@
[package]
name = "ownership"
version = "0.1.0"
authors = ["Dan Buch <daniel.buch@gmail.com>"]
[dependencies]

View File

@@ -0,0 +1,26 @@
fn main() {
let s = String::from("hello world");
let word = first_word(&s[..]);
println!("word={}", word);
let l = "hello world";
let word = first_word(&l[..]);
println!("word={}", word);
let word = first_word(l);
println!("word={}", word);
}
fn first_word(s: &str) -> &str {
let bytes = s.as_bytes();
for (i, &item) in bytes.iter().enumerate() {
if item == b' ' {
return &s[0..i];
}
}
&s[..]
}