diff --git a/Cargo.toml b/Cargo.toml index 9bcdcbb..1b53aa1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ readme = "README.md" keywords = ["read", "password", "security", "pass", "getpass"] edition = "2018" +[features] +serde = ["dep:serde", "dep:serde_json"] + [target.'cfg(unix)'.dependencies] libc = "0.2" @@ -18,5 +21,5 @@ libc = "0.2" winapi = { version = "0.3", features = ["std", "winnt", "fileapi", "processenv", "winbase", "handleapi", "consoleapi", "minwindef", "wincon"] } [dependencies] -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" +serde = { version = "1.0", features = ["derive"], optional = true } +serde_json = { version = "1.0", optional = true } diff --git a/src/rpassword/all.rs b/src/rpassword/all.rs index 5d5bde0..343c09d 100644 --- a/src/rpassword/all.rs +++ b/src/rpassword/all.rs @@ -188,11 +188,15 @@ mod windows { let hidden_input = HiddenInput::new(handle)?; - reader.read_line(&mut password)?; + let reader_return = reader.read_line(&mut password); // Newline for windows which otherwise prints on the same line. println!(); + if reader_return.is_err() { + return Err(reader_return.unwrap_err()); + } + std::mem::drop(hidden_input); super::fix_new_line(password.into_inner()) diff --git a/src/rutil.rs b/src/rutil.rs index 0d0962a..6843278 100644 --- a/src/rutil.rs +++ b/src/rutil.rs @@ -2,5 +2,6 @@ pub mod atty; pub mod fix_new_line; pub mod print_tty; pub mod safe_string; +#[cfg(feature = "serde")] pub mod safe_string_serde; pub mod safe_vec;