distractions

This commit is contained in:
LuKe Tidd 2022-12-17 09:06:05 -05:00
parent da9b8386e9
commit 9bca80091f
Signed by: luke
GPG Key ID: 75D6600BEF4E8E8F
2 changed files with 21 additions and 0 deletions

8
slice/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "slice"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

13
slice/src/main.rs Normal file
View File

@ -0,0 +1,13 @@
fn first_word(s: &String) -> usize {
let b = s.as_bytes();
for (i, &val) in b.iter().enumerate() {
if val == b' ' {
return i;
}
}
s.len()
}
fn main() {
println!("{}", first_word(&String::from("sadf sdfsd fesf")));
}