diff --git a/crates/nu-protocol/src/value/mod.rs b/crates/nu-protocol/src/value/mod.rs index 73e6dd4f7a..e55f89d586 100644 --- a/crates/nu-protocol/src/value/mod.rs +++ b/crates/nu-protocol/src/value/mod.rs @@ -366,6 +366,7 @@ impl Value { /// Returns this `Value` converted to a `str` or an error if it cannot be converted /// /// Only the following `Value` cases will return an `Ok` result: + /// - `Bool` /// - `Int` /// - `Float` /// - `String` @@ -379,7 +380,8 @@ impl Value { /// assert_eq!( /// matches!( /// val, - /// Value::Int { .. } + /// Value::Bool { .. } + /// | Value::Int { .. } /// | Value::Float { .. } /// | Value::String { .. } /// | Value::Glob { .. } @@ -392,6 +394,7 @@ impl Value { /// ``` pub fn coerce_str(&self) -> Result, ShellError> { match self { + Value::Bool { val, .. } => Ok(Cow::Owned(val.to_string())), Value::Int { val, .. } => Ok(Cow::Owned(val.to_string())), Value::Float { val, .. } => Ok(Cow::Owned(val.to_string())), Value::String { val, .. } => Ok(Cow::Borrowed(val)), @@ -419,6 +422,7 @@ impl Value { /// if you do not need to keep the original `Value` around. /// /// Only the following `Value` cases will return an `Ok` result: + /// - `Bool` /// - `Int` /// - `Float` /// - `String` @@ -432,7 +436,8 @@ impl Value { /// assert_eq!( /// matches!( /// val, - /// Value::Int { .. } + /// Value::Bool { .. } + /// | Value::Int { .. } /// | Value::Float { .. } /// | Value::String { .. } /// | Value::Glob { .. } @@ -450,6 +455,7 @@ impl Value { /// Returns this `Value` converted to a `String` or an error if it cannot be converted /// /// Only the following `Value` cases will return an `Ok` result: + /// - `Bool` /// - `Int` /// - `Float` /// - `String` @@ -463,7 +469,8 @@ impl Value { /// assert_eq!( /// matches!( /// val, - /// Value::Int { .. } + /// Value::Bool { .. } + /// | Value::Int { .. } /// | Value::Float { .. } /// | Value::String { .. } /// | Value::Glob { .. } @@ -477,6 +484,7 @@ impl Value { pub fn coerce_into_string(self) -> Result { let span = self.span(); match self { + Value::Bool { val, .. } => Ok(val.to_string()), Value::Int { val, .. } => Ok(val.to_string()), Value::Float { val, .. } => Ok(val.to_string()), Value::String { val, .. } => Ok(val),