diff --git a/Chapter10/command-line-args/src/main.rs b/Chapter10/command-line-args/src/main.rs index 8e658e9..81d0d62 100644 --- a/Chapter10/command-line-args/src/main.rs +++ b/Chapter10/command-line-args/src/main.rs @@ -16,7 +16,7 @@ impl Exclusion { fn walk( dir: &Path, exclusion: &Option, - cb: &Fn(&DirEntry), + cb: &dyn Fn(&DirEntry), recurse: bool, ) -> io::Result<()> { for entry in dir.read_dir()? { @@ -86,10 +86,9 @@ fn main() -> io::Result<()> { ) .get_matches(); - let filter_conf = matches.value_of("match").unwrap_or(""); let recurse = matches.is_present("recursive"); let exclusions = matches.value_of("exclude").map(|e| Exclusion(e.into())); - + match matches.subcommand() { ("files", Some(subcmd)) => { let path = Path::new(subcmd.value_of("PATH").unwrap()); diff --git a/Chapter10/logging/log4rs.yml b/Chapter10/logging/log4rs.yml index 575afbc..6ae2709 100644 --- a/Chapter10/logging/log4rs.yml +++ b/Chapter10/logging/log4rs.yml @@ -1,4 +1,3 @@ -# Scan this file for changes every 30 seconds refresh_rate: 30 seconds appenders: @@ -20,5 +19,4 @@ loggers: special-target: level: info appenders: - - outfile - additive: false \ No newline at end of file + - outfile \ No newline at end of file diff --git a/Chapter10/logging/outfile.log b/Chapter10/logging/outfile.log index a9ecb1d..d8de4bd 100644 --- a/Chapter10/logging/outfile.log +++ b/Chapter10/logging/outfile.log @@ -1,2 +1 @@ -2019-08-20T13:18:17.023781824+02:00 - WARNING, stuff is breaking down -2019-08-21T18:50:13.813701633+02:00 - WARNING, stuff is breaking down +2019-09-01T12:45:25.256922311+02:00 - WARNING, stuff is breaking down diff --git a/Chapter10/logging/src/main.rs b/Chapter10/logging/src/main.rs index a54fad2..7d4f8e7 100644 --- a/Chapter10/logging/src/main.rs +++ b/Chapter10/logging/src/main.rs @@ -50,7 +50,7 @@ fn log_some_stuff() { error!("ERROR: stopping ..."); } -const USE_CUSTOM: bool = false; +const USE_CUSTOM: bool = true; fn main() { if USE_CUSTOM { diff --git a/Chapter10/rusty-ml/models/best.ot b/Chapter10/rusty-ml/models/best.ot deleted file mode 100644 index c3953eb..0000000 Binary files a/Chapter10/rusty-ml/models/best.ot and /dev/null differ diff --git a/Chapter10/rusty-ml/models/latest.tch b/Chapter10/rusty-ml/models/latest.tch deleted file mode 100644 index e9e5c73..0000000 Binary files a/Chapter10/rusty-ml/models/latest.tch and /dev/null differ diff --git a/Chapter10/sub-processes/src/main.rs b/Chapter10/sub-processes/src/main.rs index 65816c3..b489ecc 100644 --- a/Chapter10/sub-processes/src/main.rs +++ b/Chapter10/sub-processes/src/main.rs @@ -4,21 +4,27 @@ use std::process::{Command, Stdio}; fn main() -> Result<(), Box> { let mut ls_child = Command::new("ls"); - ls_child.args(&["-alh"]); - ls_child.status()?; + if !cfg!(target_os = "windows") { + ls_child.args(&["-alh"]); + } + println!("{}", ls_child.status()?); ls_child.current_dir("src/"); - + println!("{}", ls_child.status()?); + let env_child = Command::new("env") .env("CANARY", "0x5ff") .stdout(Stdio::piped()) .spawn()?; - + let env_output = &env_child.wait_with_output()?; - let canary = String::from_utf8_lossy(&env_output.stdout).split_ascii_whitespace().filter(|line| *line == "CANARY=0x5ff").count(); + let canary = String::from_utf8_lossy(&env_output.stdout) + .split_ascii_whitespace() + .filter(|line| *line == "CANARY=0x5ff") + .count(); // found it! assert_eq!(canary, 1); - + let mut rev_child = Command::new("rev") .stdin(Stdio::piped()) .stdout(Stdio::piped())