Skip to content

Commit

Permalink
add an example without length
Browse files Browse the repository at this point in the history
  • Loading branch information
nibon7 committed Feb 13, 2024
1 parent 671ff9e commit a7961f8
Showing 1 changed file with 40 additions and 19 deletions.
59 changes: 40 additions & 19 deletions crates/nu-cmd-dataframe/src/dataframe/series/string/str_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,46 @@ impl Command for StrSlice {
}

fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Creates slices from the strings",
example: "[abcded abc321 abc123] | dfr into-df | dfr str-slice 1 --length 2",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
"0".to_string(),
vec![
Value::test_string("bc"),
Value::test_string("bc"),
Value::test_string("bc"),
],
)],
None,
)
.expect("simple df for test should not fail")
.into_value(Span::test_data()),
),
}]
vec![
Example {
description: "Creates slices from the strings",
example: "[abcded abc321 abc123] | dfr into-df | dfr str-slice 1 --length 2",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
"0".to_string(),
vec![
Value::test_string("bc"),
Value::test_string("bc"),
Value::test_string("bc"),
],
)],
None,
)
.expect("simple df for test should not fail")
.into_value(Span::test_data()),
),
},
Example {
description: "Creates slices from the strings without length",
example: "[abcded abc321 abc123] | dfr into-df | dfr str-slice 1",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
"0".to_string(),
vec![
Value::test_string("bcded"),
Value::test_string("bc321"),
Value::test_string("bc123"),
],
)],
None,
)
.expect("simple df for test should not fail")
.into_value(Span::test_data()),
),
},
]
}

fn run(
Expand Down

0 comments on commit a7961f8

Please sign in to comment.