mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 08:48:51 +02:00
Remove the line primitive (#2887)
This commit is contained in:
@ -140,7 +140,6 @@ impl Type {
|
||||
Primitive::Decimal(_) => Type::Decimal,
|
||||
Primitive::Filesize(_) => Type::Filesize,
|
||||
Primitive::String(_) => Type::String,
|
||||
Primitive::Line(_) => Type::Line,
|
||||
Primitive::ColumnPath(_) => Type::ColumnPath,
|
||||
Primitive::Pattern(_) => Type::Pattern,
|
||||
Primitive::Boolean(_) => Type::Boolean,
|
||||
|
@ -162,11 +162,6 @@ impl UntaggedValue {
|
||||
UntaggedValue::Primitive(Primitive::String(s.into()))
|
||||
}
|
||||
|
||||
/// Helper for creating line values
|
||||
pub fn line(s: impl Into<String>) -> UntaggedValue {
|
||||
UntaggedValue::Primitive(Primitive::Line(s.into()))
|
||||
}
|
||||
|
||||
/// Helper for creating column-path values
|
||||
pub fn column_path(s: &str, span: Span) -> UntaggedValue {
|
||||
let s = s.to_string().spanned(span);
|
||||
@ -317,7 +312,6 @@ impl Value {
|
||||
pub fn as_string(&self) -> Result<String, ShellError> {
|
||||
match &self.value {
|
||||
UntaggedValue::Primitive(Primitive::String(string)) => Ok(string.clone()),
|
||||
UntaggedValue::Primitive(Primitive::Line(line)) => Ok(line.clone() + "\n"),
|
||||
UntaggedValue::Primitive(Primitive::Path(path)) => {
|
||||
Ok(path.to_string_lossy().to_string())
|
||||
}
|
||||
@ -584,8 +578,6 @@ pub trait StringExt {
|
||||
fn to_string_untagged_value(&self) -> UntaggedValue;
|
||||
fn to_string_value(&self, tag: Tag) -> Value;
|
||||
fn to_string_value_create_tag(&self) -> Value;
|
||||
fn to_line_value(&self, tag: Tag) -> Value;
|
||||
fn to_line_untagged_value(&self) -> UntaggedValue;
|
||||
fn to_column_path_value(&self, tag: Tag) -> Value;
|
||||
fn to_column_path_untagged_value(&self, span: Span) -> UntaggedValue;
|
||||
fn to_pattern_value(&self, tag: Tag) -> Value;
|
||||
@ -615,17 +607,6 @@ impl StringExt for String {
|
||||
UntaggedValue::string(self)
|
||||
}
|
||||
|
||||
fn to_line_value(&self, the_tag: Tag) -> Value {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Line(self.to_string())),
|
||||
tag: the_tag,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_line_untagged_value(&self) -> UntaggedValue {
|
||||
UntaggedValue::line(self)
|
||||
}
|
||||
|
||||
fn to_column_path_value(&self, the_tag: Tag) -> Value {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::ColumnPath(ColumnPath::build(
|
||||
@ -656,8 +637,6 @@ pub trait StrExt {
|
||||
fn to_str_untagged_value(&self) -> UntaggedValue;
|
||||
fn to_str_value(&self, tag: Tag) -> Value;
|
||||
fn to_str_value_create_tag(&self) -> Value;
|
||||
fn to_line_value(&self, tag: Tag) -> Value;
|
||||
fn to_line_untagged_value(&self) -> UntaggedValue;
|
||||
fn to_column_path_value(&self, tag: Tag) -> Value;
|
||||
fn to_column_path_untagged_value(&self, span: Span) -> UntaggedValue;
|
||||
fn to_pattern_value(&self, tag: Tag) -> Value;
|
||||
@ -687,17 +666,6 @@ impl StrExt for &str {
|
||||
UntaggedValue::string(*self)
|
||||
}
|
||||
|
||||
fn to_line_value(&self, the_tag: Tag) -> Value {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::Line(self.to_string())),
|
||||
tag: the_tag,
|
||||
}
|
||||
}
|
||||
|
||||
fn to_line_untagged_value(&self) -> UntaggedValue {
|
||||
UntaggedValue::line(*self)
|
||||
}
|
||||
|
||||
fn to_column_path_value(&self, the_tag: Tag) -> Value {
|
||||
Value {
|
||||
value: UntaggedValue::Primitive(Primitive::ColumnPath(ColumnPath::build(
|
||||
@ -1015,12 +983,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_to_line_untagged_value() {
|
||||
let a_line = r"this is some line\n";
|
||||
assert_eq!(a_line.to_line_untagged_value(), UntaggedValue::line(a_line));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_string_to_pattern_untagged_value() {
|
||||
let a_pattern = r"[a-zA-Z0-9 ]";
|
||||
|
@ -35,7 +35,6 @@ impl PrettyType for Primitive {
|
||||
Primitive::Decimal(_) => ty("decimal"),
|
||||
Primitive::Filesize(_) => ty("filesize"),
|
||||
Primitive::String(_) => ty("string"),
|
||||
Primitive::Line(_) => ty("line"),
|
||||
Primitive::ColumnPath(_) => ty("column-path"),
|
||||
Primitive::Pattern(_) => ty("pattern"),
|
||||
Primitive::Boolean(_) => ty("boolean"),
|
||||
@ -73,7 +72,6 @@ impl PrettyDebug for Primitive {
|
||||
}
|
||||
Primitive::Filesize(bytes) => primitive_doc(bytes, "filesize"),
|
||||
Primitive::String(string) => prim(string),
|
||||
Primitive::Line(string) => prim(string),
|
||||
Primitive::ColumnPath(path) => path.pretty(),
|
||||
Primitive::Pattern(pattern) => primitive_doc(pattern, "pattern"),
|
||||
Primitive::Boolean(boolean) => match boolean {
|
||||
|
@ -34,8 +34,6 @@ pub enum Primitive {
|
||||
Filesize(u64),
|
||||
/// A string value
|
||||
String(String),
|
||||
/// A string value with an implied carriage return (or cr/lf) ending
|
||||
Line(String),
|
||||
/// A path to travel to reach a value in a table
|
||||
ColumnPath(ColumnPath),
|
||||
/// A glob pattern, eg foo*
|
||||
@ -235,7 +233,6 @@ impl ShellTypeName for Primitive {
|
||||
Primitive::Decimal(_) => "decimal",
|
||||
Primitive::Filesize(_) => "filesize(in bytes)",
|
||||
Primitive::String(_) => "string",
|
||||
Primitive::Line(_) => "line",
|
||||
Primitive::ColumnPath(_) => "column path",
|
||||
Primitive::Pattern(_) => "pattern",
|
||||
Primitive::Boolean(_) => "boolean",
|
||||
@ -294,7 +291,6 @@ pub fn format_primitive(primitive: &Primitive, field_name: Option<&String>) -> S
|
||||
),
|
||||
Primitive::Pattern(s) => s.to_string(),
|
||||
Primitive::String(s) => s.to_owned(),
|
||||
Primitive::Line(s) => s.to_owned(),
|
||||
Primitive::ColumnPath(p) => {
|
||||
let mut members = p.iter();
|
||||
let mut f = String::new();
|
||||
|
Reference in New Issue
Block a user