Repository: nushell/nushell
File: crates/nu-protocol/src/signature.rs (Rust)

Code before:
    ///
    /// If the signature has several input-output pairs the first one is
    /// returned.  If the input was unspecified [`Type::Any`] is returned.
    pub fn get_input_type(&self) -> Type {
        match self.input_output_types.len() {
            0 => Type::Any,
            1 => self.input_output_types[0].0.clone(),
            _ => {
                let first = &self.input_output_types[0].0;
                if self
                    .input_output_types
                    .iter()
                    .all(|(input, _)| input == first)
                {
                    first.clone()
                } else {
                    Type::Any
                }
            }
        }
    }

    /// Gets the output type from the signature
    ///
    /// If the signature has several input-output pairs the first one is
    /// returned.  If the output was unspecified, [`Type::Any`] is returned.
    pub fn get_output_type(&self) -> Type {
        match self.input_output_types.len() {
            0 => Type::Any,
            1 => self.input_output_types[0].1.clone(),
            _ => {
                let first = &self.input_output_types[0].1;
                if self
                    .input_output_types
                    .iter()
                    .all(|(_, output)| output == first)
                {
                    first.clone()
                } else {
                    Type::Any
                }
            }
        }
    }

    /// Add a default help option to a signature
    pub fn add_help(mut self) -> Signature {
        // default help flag
        let flag = Flag {
            long: "help".into(),
            short: Some('h'),

Review comment (bug):
This description is incorrect it will either return `Any` or the specific type if it is the only output type shared across all pairs.

I somewhat question the utility of this method. If it is not actively used it should probably go. (the type checker needs a more advanced mechanism anyways)

Code after:
    ///
    /// If the input was unspecified or the signature has several different
    /// input types, [`Type::Any`] is returned.  Otherwise, if the signature has
    /// one or same input types, this type is returned.
    // XXX: remove?
    pub fn get_input_type(&self) -> Type {
        match self.input_output_types.len() {
            0 => Type::Any,
            1 => self.input_output_types[0].0.clone(),
            _ => {
                let first = &self.input_output_types[0].0;
                if self
                    .input_output_types
                    .iter()
                    .all(|(input, _)| input == first)
                {
                    first.clone()
                } else {
                    Type::Any
                }
            }
        }
    }

    /// Gets the output type from the signature
    ///
    /// If the output was unspecified or the signature has several different
    /// input types, [`Type::Any`] is returned.  Otherwise, if the signature has
    /// one or same output types, this type is returned.
    // XXX: remove?
    pub fn get_output_type(&self) -> Type {
        match self.input_output_types.len() {
            0 => Type::Any,
            1 => self.input_output_types[0].1.clone(),
            _ => {
                let first = &self.input_output_types[0].1;
                if self
                    .input_output_types
                    .iter()
                    .all(|(_, output)| output == first)
                {
                    first.clone()
                } else {
                    Type::Any
                }
            }
        }
    }

    /// Add a default help option to a signature
    pub fn add_help(mut self) -> Signature {