Repository: casey/just
File: src/positional.rs (Rust)

Code before:
    let mut search_directory = None;
    let mut arguments = Vec::new();

    let mut processing_step = ProcessingStep::Overrides;

    if let Some(values) = values {
      for value in values {
        if let ProcessingStep::Overrides = processing_step {
          if let Some(o) = Self::override_from_value(value) {
            overrides.push(o);
            continue;
          }
          processing_step = ProcessingStep::SearchDir;
        }

        if let ProcessingStep::SearchDir = processing_step {
          if value == "." || value == ".." {
            search_directory = Some(value.to_owned());
            continue;
          } else if let Some(i) = value.rfind('/') {
            let (dir, tail) = value.split_at(i + 1);

            if let Some(ref sdir) = search_directory {
              if sdir != dir {
                return Err(ConfigError::MultipleSearchDir {
                  seen: sdir.clone(),
                  conflicting: dir.to_string(),
                });
              }
            } else {
              search_directory = Some(dir.to_owned());
            }

            if !tail.is_empty() {
              arguments.push(tail.to_owned());
            }
            continue;
          }
          processing_step = ProcessingStep::Arguments;
        }

        arguments.push(value.to_owned());
      }
    }

    Ok(Self {
      overrides,
      search_directory,
      arguments,
    })
  }

Review comment (suggestion):
```suggestion
                  seen: seen.clone(),
```

Code after:
    let mut search_directory = None;
    let mut arguments = Vec::new();

    let mut processing_step = ProcessingStep::Overrides;

    if let Some(values) = values {
      let mut values = values.into_iter().peekable();
      while let Some(value) = values.peek() {
        let value = *value;
        match processing_step {
          ProcessingStep::Overrides => {
            if let Some(o) = Self::override_from_value(value) {
              overrides.push(o);
              values.next();
            } else {
              processing_step = ProcessingStep::SearchDir;
            }
          }
          ProcessingStep::SearchDir => {
            if value == "." || value == ".." {
              search_directory = Some(value.to_owned());
              values.next();
            } else if let Some(i) = value.rfind('/') {
              let (dir, tail) = value.split_at(i + 1);

              if let Some(ref seen) = search_directory {
                if seen != dir {
                  return Err(ConfigError::ConflictingSearchDirArgs {
                    seen: seen.clone(),
                    conflicting: dir.into(),
                  });
                }
              } else {
                search_directory = Some(dir.to_owned());
              }

              if !tail.is_empty() {
                arguments.push(tail.to_owned());
              }
              values.next();
            } else {
              processing_step = ProcessingStep::Arguments;
            }
          }
          ProcessingStep::Arguments => {
            arguments.push(value.to_owned());
            values.next();
          }
        }
      }
    }