mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 09:23:38 +01:00
change str distance to output value::int (#6963)
* change str distance to output value::int * update the test
This commit is contained in:
parent
0b4daa66b0
commit
f48de73236
4
.gitignore
vendored
4
.gitignore
vendored
@ -22,6 +22,10 @@ debian/nu/
|
||||
# VSCode's IDE items
|
||||
.vscode/*
|
||||
|
||||
# Visual Studio Extension SourceGear Rust items
|
||||
VSWorkspaceSettings.json
|
||||
unstable_cargo_features.txt
|
||||
|
||||
# Helix configuration folder
|
||||
.helix/*
|
||||
.helix
|
||||
|
@ -70,13 +70,9 @@ impl Command for SubCommand {
|
||||
vec![Example {
|
||||
description: "get the edit distance between two strings",
|
||||
example: "'nushell' | str distance 'nutshell'",
|
||||
result: Some(Value::Record {
|
||||
cols: vec!["distance".to_string()],
|
||||
vals: vec![Value::Int {
|
||||
result: Some(Value::Int {
|
||||
val: 1,
|
||||
span: Span::test_data(),
|
||||
}],
|
||||
span: Span::test_data(),
|
||||
}),
|
||||
}]
|
||||
}
|
||||
@ -87,13 +83,9 @@ fn action(input: &Value, args: &Arguments, head: Span) -> Value {
|
||||
match &input {
|
||||
Value::String { val, .. } => {
|
||||
let distance = levenshtein_distance(val, compare_string);
|
||||
Value::Record {
|
||||
cols: vec!["distance".to_string()],
|
||||
vals: vec![Value::Int {
|
||||
Value::Int {
|
||||
val: distance as i64,
|
||||
span: head,
|
||||
}],
|
||||
span: head,
|
||||
}
|
||||
}
|
||||
other => Value::Error {
|
||||
|
Loading…
Reference in New Issue
Block a user