I trying my hand in Rust after coding for full time in Python for 6 years (2.5 years in C# and 6 years in Perl in that order). I tried reading books but i was missing the real problems and thats when i decided to convert simple shell script to Rust (its gives no benefit to convert but it was only for learning). I spent about 1 hr / day for 4 days (not consecutive) to covert the code to Rust, it works and does what i wanted to do but i have no idea how good the code is or how can it be improved?
If anyone of you have some time to spare and could you please review my PR https://github.com/ninadmhatre/rust_practice/pull/1
There are few queries:
- I am running OS command using
std::process::Commandhow can i print / log the whole command being executed?
- Stdout / Stderr is buffered above, so even with Stdio i am not able to see output / errors logged in file on real time? i got this from 1 recipe i found online.
- I have few variables in config.rs but how do i orverride them with env variable? I tried env module but then i have to make sure its defined and then only use it (i can achieve this with other function but just asking if it can be done in 1 line w/o panic)
- I am doing lot of “str”.to_string or “String”.as_str is correct? or can be avoided?
I am yet to finish the rust by example but i was getting tried of not doing anything with it so yes this is done with half knowledge of all of the Rust. But i am happy that i can produce something that works now need to learn more.
I am using Rust 1.32 2018 edition on linux