Skip to content

Commit

Permalink
style: apply automated clippy lint fixes
Browse files Browse the repository at this point in the history
Related to #16
  • Loading branch information
LeoniePhiline committed Nov 21, 2024
1 parent d7b2cb3 commit f1f6b1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 1 addition & 4 deletions examples/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ fn connect(host: &str, params: &HostParams) {
Some(h) => h,
None => host,
};
let port = match params.port {
None => 22,
Some(p) => p,
};
let port = params.port.unwrap_or(22);
let host = match host.contains(':') {
true => host.to_string(),
false => format!("{}:{}", host, port),
Expand Down
10 changes: 5 additions & 5 deletions src/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ impl SshConfigParser {

/// parse boolean value
fn parse_boolean(args: Vec<String>) -> SshParserResult<bool> {
match args.get(0).map(|x| x.as_str()) {
match args.first().map(|x| x.as_str()) {
Some("yes") => Ok(true),
Some("no") => Ok(false),
Some(_) => Err(SshParserError::ExpectedBoolean),
Expand All @@ -315,7 +315,7 @@ impl SshConfigParser {
/// Parse comma separated list arguments
fn parse_comma_separated_list(args: Vec<String>) -> SshParserResult<Vec<String>> {
match args
.get(0)
.first()
.map(|x| x.split(',').map(|x| x.to_string()).collect())
{
Some(args) => Ok(args),
Expand Down Expand Up @@ -360,7 +360,7 @@ impl SshConfigParser {

/// Parse path argument
fn parse_path(args: Vec<String>) -> SshParserResult<PathBuf> {
if let Some(s) = args.get(0) {
if let Some(s) = args.first() {
Self::parse_path_arg(s)
} else {
Err(SshParserError::MissingArgument)
Expand All @@ -384,7 +384,7 @@ impl SshConfigParser {

/// Parse port number argument
fn parse_port(args: Vec<String>) -> SshParserResult<u16> {
match args.get(0).map(|x| u16::from_str(x)) {
match args.first().map(|x| u16::from_str(x)) {
Some(Ok(val)) => Ok(val),
Some(Err(_)) => Err(SshParserError::ExpectedPort),
None => Err(SshParserError::MissingArgument),
Expand All @@ -402,7 +402,7 @@ impl SshConfigParser {

/// Parse unsigned argument
fn parse_unsigned(args: Vec<String>) -> SshParserResult<usize> {
match args.get(0).map(|x| usize::from_str(x)) {
match args.first().map(|x| usize::from_str(x)) {
Some(Ok(val)) => Ok(val),
Some(Err(_)) => Err(SshParserError::ExpectedUnsigned),
None => Err(SshParserError::MissingArgument),
Expand Down

0 comments on commit f1f6b1b

Please sign in to comment.