chiya@ujimatsu:~/Works/hello_rust/hello_rust_string$ cargo run
Compiling hello_rust v0.1.0 (/home/chiya/Works/hello_rust/hello_rust_string)
Finished dev [unoptimized + debuginfo] target(s) in 0.36s
Running `target/debug/hello_rust`
Hello, world! 1
odd number
Hello, world! 2
even number
Hello, world! 3
odd number
Hello, world! 4
even number
H
e
l
l
o
fn main() {
let str_hello = "Hello";
let str_world = "world!";
let str_hello_world = String::from(str_hello) + ", " + str_world;
let str_even = "even number";
let str_odd = "odd number";
for n in 1..5 {
println!("{} {}", str_hello_world, n);
if n%2 == 0 {
println!(" {}", str_even);
}
else {
println!(" {}", str_odd);
}
}
for i in str_hello.chars() {
println!("{}", i);
}
}