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

Code before:
                    (Value::String { .. }, PathMember::Int { .. })
                    | (Value::Int { .. }, PathMember::String { .. }) => false,
                    _ => unreachable!(
                        "outer match arm ensures `self` is either a `String` or `Int` variant"
                    ),
                });

                Ok(Value::bool(val, span))
            }
            (Value::CellPath { val: lhs, .. }, Value::CellPath { val: rhs, .. }) => {
                Ok(Value::bool(
                    rhs.members
                        .windows(lhs.members.len())
                        .any(|member_window| member_window == rhs.members),
                    span,
                ))
            }
            (Value::Custom { val: lhs, .. }, rhs) => {
                lhs.operation(self.span(), Operator::Comparison(Comparison::In), op, rhs)
            }
            (lhs, rhs) => Err(
                if matches!(
                    rhs,
                    Value::List { .. }
                        | Value::Range { .. }
                        | Value::String { .. }
                        | Value::Record { .. }
                        | Value::Custom { .. }
                ) {
                    ShellError::OperatorIncompatibleTypes {
                        op: Operator::Comparison(Comparison::In),
                        lhs: lhs.get_type(),
                        rhs: rhs.get_type(),
                        op_span: op,
                        lhs_span: lhs.span(),
                        rhs_span: rhs.span(),
                        help: None,
                    }
                } else {
                    ShellError::OperatorUnsupportedType {
                        op: Operator::Comparison(Comparison::In),
                        unsupported: rhs.get_type(),
                        op_span: op,
                        unsupported_span: rhs.span(),
                        help: None,
                    }
                },
            ),
        }
    }


Review comment (suggestion):
I think that is one of the gray areas where the `matches!` form maybe has a benefit of making it more obvious what we care about first namely that we match the right hand side (and then you read all the covered patterns)

Code after:
                    (Value::String { .. }, PathMember::Int { .. })
                    | (Value::Int { .. }, PathMember::String { .. }) => false,
                    _ => unreachable!(
                        "outer match arm ensures `self` is either a `String` or `Int` variant"
                    ),
                });

                Ok(Value::bool(val, span))
            }
            (Value::CellPath { val: lhs, .. }, Value::CellPath { val: rhs, .. }) => {
                Ok(Value::bool(
                    rhs.members
                        .windows(lhs.members.len())
                        .any(|member_window| member_window == rhs.members),
                    span,
                ))
            }
            (Value::Custom { val: lhs, .. }, rhs) => {
                lhs.operation(self.span(), Operator::Comparison(Comparison::In), op, rhs)
            }
            (lhs, rhs) => Err(
                if let Value::List { .. }
                | Value::Range { .. }
                | Value::String { .. }
                | Value::Record { .. }
                | Value::Custom { .. } = rhs
                {
                    ShellError::OperatorIncompatibleTypes {
                        op: Operator::Comparison(Comparison::In),
                        lhs: lhs.get_type(),
                        rhs: rhs.get_type(),
                        op_span: op,
                        lhs_span: lhs.span(),
                        rhs_span: rhs.span(),
                        help: None,
                    }
                } else {
                    ShellError::OperatorUnsupportedType {
                        op: Operator::Comparison(Comparison::In),
                        unsupported: rhs.get_type(),
                        op_span: op,
                        unsupported_span: rhs.span(),
                        help: None,
                    }
                },
            ),
        }
    }

    pub fn not_in(&self, op: Span, rhs: &Value, span: Span) -> Result<Value, ShellError> {
        match (self, rhs) {