Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
rufevean authored Sep 3, 2024
2 parents e7c3280 + 5d30ce6 commit cde62e4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
17 changes: 8 additions & 9 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,16 +462,15 @@ fn print_version() {

fn determine_operation(matches: &Matches) -> Result<Operation, OperationError> {
if matches.opt_present("h") {
let topic = matches.opt_str("h");
if topic.is_none() {
let Some(topic) = matches.opt_str("h") else {
return Ok(Operation::Help(HelpOp::None));
} else if topic == Some("config".to_owned()) {
return Ok(Operation::Help(HelpOp::Config));
} else if topic == Some("file-lines".to_owned()) && is_nightly() {
return Ok(Operation::Help(HelpOp::FileLines));
} else {
return Err(OperationError::UnknownHelpTopic(topic.unwrap()));
}
};

return match topic.as_str() {
"config" => Ok(Operation::Help(HelpOp::Config)),
"file-lines" if is_nightly() => Ok(Operation::Help(HelpOp::FileLines)),
_ => Err(OperationError::UnknownHelpTopic(topic)),
};
}
let mut free_matches = matches.free.iter();

Expand Down
9 changes: 5 additions & 4 deletions src/comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,10 +533,11 @@ impl ItemizedBlock {

/// Returns the block as a string, with each line trimmed at the start.
fn trimmed_block_as_string(&self) -> String {
self.lines
.iter()
.map(|line| format!("{} ", line.trim_start()))
.collect::<String>()
self.lines.iter().fold(String::new(), |mut acc, line| {
acc.push_str(line.trim_start());
acc.push(' ');
acc
})
}

/// Returns the block as a string under its original form.
Expand Down

0 comments on commit cde62e4

Please sign in to comment.