Skip to content

Commit

Permalink
style: cargo fmt again
Browse files Browse the repository at this point in the history
  • Loading branch information
39555 committed Oct 13, 2024
1 parent cca73ce commit ef8094c
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 22 deletions.
10 changes: 5 additions & 5 deletions brush-core/src/builtins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,7 @@ fn brush_help_styles() -> clap::builder::Styles {
/// # Returns
///
/// * a parsed struct T from [`clap::Parser::parse_from`]
/// * the remain iterator `args` with `--` and the rest arguments if they present
/// othervise None
/// * the remain iterator `args` with `--` and the rest arguments if they present othervise None
///
/// # Examples
/// ```
Expand All @@ -421,8 +420,8 @@ where
S: Into<std::ffi::OsString> + Clone + PartialEq<&'static str>,
{
let mut args = args.into_iter();
// the best way to save `--` is to get it out with a side effect while `clap` iterates over the args
// this way we can be 100% sure that we have '--' and the remaining args
// the best way to save `--` is to get it out with a side effect while `clap` iterates over the
// args this way we can be 100% sure that we have '--' and the remaining args
// and we will iterate only once
let mut hyphen = None;
let args_before_hyphen = args.by_ref().take_while(|a| {
Expand All @@ -438,7 +437,8 @@ where
}

/// Similar to [`parse_known`] but with [`clap::Parser::try_parse_from`]
/// This function is used to parse arguments in builtins such as [`crate::builtins::echo::EchoCommand`]
/// This function is used to parse arguments in builtins such as
/// [`crate::builtins::echo::EchoCommand`]
pub fn try_parse_known<T: Parser>(
args: impl IntoIterator<Item = String>,
) -> Result<(T, Option<impl Iterator<Item = String>>), clap::Error> {
Expand Down
1 change: 0 additions & 1 deletion brush-core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,4 +190,3 @@ pub enum Error {
pub(crate) fn unimp<T>(msg: &'static str) -> Result<T, Error> {
Err(Error::Unimplemented(msg))
}

20 changes: 11 additions & 9 deletions brush-core/src/variables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ impl ShellVariable {

if append {
match (&self.value, &value) {
// If we're appending an array to a declared-but-unset variable (or appending anything to a declared-but-unset array),
// then fill it out first.
// If we're appending an array to a declared-but-unset variable (or appending
// anything to a declared-but-unset array), then fill it out first.
(ShellValue::Unset(_), ShellValueLiteral::Array(_))
| (
ShellValue::Unset(
Expand All @@ -226,8 +226,8 @@ impl ShellVariable {
) => {
self.assign(ShellValueLiteral::Array(ArrayLiteral(vec![])), false)?;
}
// If we're trying to append an array to a string, we first promote the string to be an array
// with the string being present at index 0.
// If we're trying to append an array to a string, we first promote the string to be
// an array with the string being present at index 0.
(ShellValue::String(_), ShellValueLiteral::Array(_)) => {
self.convert_to_indexed_array()?;
}
Expand Down Expand Up @@ -289,9 +289,9 @@ impl ShellVariable {
ShellValueLiteral::Scalar(s),
) => self.assign_at_index(String::from("0"), s, false),

// If we're updating an indexed array value with an array, then preserve the array type.
// We also default to using an indexed array if we are assigning an array to a previously
// string-holding variable.
// If we're updating an indexed array value with an array, then preserve the array
// type. We also default to using an indexed array if we are
// assigning an array to a previously string-holding variable.
(
ShellValue::IndexedArray(_)
| ShellValue::Unset(
Expand All @@ -305,7 +305,8 @@ impl ShellVariable {
Ok(())
}

// If we're updating an associative array value with an array, then preserve the array type.
// If we're updating an associative array value with an array, then preserve the
// array type.
(
ShellValue::AssociativeArray(_)
| ShellValue::Unset(ShellValueUnsetType::AssociativeArray),
Expand Down Expand Up @@ -334,7 +335,8 @@ impl ShellVariable {
///
/// * `array_index` - The index at which to assign the value.
/// * `value` - The value to assign to the variable at the given index.
/// * `append` - Whether or not to append the value to the preexisting value stored at the given index.
/// * `append` - Whether or not to append the value to the preexisting value stored at the given
/// index.
#[allow(clippy::needless_pass_by_value)]
pub fn assign_at_index(
&mut self,
Expand Down
3 changes: 2 additions & 1 deletion brush-interactive/src/reedline/highlighter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ impl<'a> StyledInputLine<'a> {
}

fn skip_ahead(&mut self, dest: usize) {
// Append a no-op style to make sure we cover any trailing gaps in the input line not otherwise styled.
// Append a no-op style to make sure we cover any trailing gaps in the input line not
// otherwise styled.
self.append_style(Style::new(), dest, dest);
}

Expand Down
2 changes: 0 additions & 2 deletions brush-shell/src/brushctl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ enum EventsCommand {
},
}


impl brush_core::builtins::Command for BrushCtlCommand {
async fn execute(
&self,
Expand All @@ -54,7 +53,6 @@ impl brush_core::builtins::Command for BrushCtlCommand {
}
}


impl EventsCommand {
fn execute(
&self,
Expand Down
4 changes: 0 additions & 4 deletions brush-shell/src/shell_factory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

pub(crate) trait ShellFactory {
type ShellType: brush_interactive::InteractiveShell + Send;

Expand Down Expand Up @@ -53,7 +52,6 @@ impl AsMut<brush_core::Shell> for StubShell {

pub(crate) struct RustylineShellFactory;


impl ShellFactory for RustylineShellFactory {
#[cfg(all(feature = "rustyline", any(windows, unix)))]
type ShellType = brush_interactive::RustylineShell;
Expand All @@ -78,7 +76,6 @@ impl ShellFactory for RustylineShellFactory {

pub(crate) struct ReedlineShellFactory;


impl ShellFactory for ReedlineShellFactory {
#[cfg(all(feature = "reedline", any(windows, unix)))]
type ShellType = brush_interactive::ReedlineShell;
Expand All @@ -103,7 +100,6 @@ impl ShellFactory for ReedlineShellFactory {

pub(crate) struct BasicShellFactory;


impl ShellFactory for BasicShellFactory {
#[cfg(feature = "basic")]
type ShellType = brush_interactive::BasicShell;
Expand Down

0 comments on commit ef8094c

Please sign in to comment.