forked from conradkleinespel/rpassword
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added rust-version in Cargo.toml (fixes issue conradkleinespel#73) an…
…d updated string cleanup to handle ctrl+u (fixes issue conradkleinespel#70)
- Loading branch information
Showing
5 changed files
with
45 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/// Normalizes the return of `read_line()` in the context of a CLI application | ||
pub fn fix_line_issues(mut line: String) -> std::io::Result<String> { | ||
if !line.ends_with('\n') { | ||
return Err(std::io::Error::new( | ||
std::io::ErrorKind::UnexpectedEof, | ||
"unexpected end of file", | ||
)); | ||
} | ||
|
||
// Remove the \n from the line. | ||
line.pop(); | ||
|
||
// Remove the \r from the line if present | ||
if line.ends_with('\r') { | ||
line.pop(); | ||
} | ||
|
||
if line.contains("") { | ||
let vec: Vec<&str> = line.split("").collect(); | ||
line = match vec.last() { | ||
None => String::new(), | ||
Some(i) => i.to_string() | ||
} | ||
} | ||
|
||
Ok(line) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters