Skip to content

Commit cbcc4bd

Browse files
authored
Fix plugins streaming sample (#1908)
Please verify as I am not very familiar with Rust. Tested working with a `seq` stream, a string, and a list of values as I would expect from the implementation. Content that follows on the page has not been tested or adjusted. Resolves #1734
1 parent 2adb836 commit cbcc4bd

File tree

1 file changed

+13
-20
lines changed

1 file changed

+13
-20
lines changed

contributor-book/plugins.md

+13-20
Original file line numberDiff line numberDiff line change
@@ -328,27 +328,20 @@ impl PluginCommand for Len {
328328
Value::int(length as i64, call.head).into_pipeline_data()
329329
)
330330
},
331-
input => {
332-
// Handle a string
333-
let span = input.span().unwrap_or(call.head);
334-
let value = input.into_value(span);
335-
match &value {
336-
Value::String { val, .. } => Ok(
337-
Value::int(val.len() as i64, value.span()).into_pipeline_data()
338-
),
339-
_ => Err(
340-
LabeledError::new(
341-
"Expected String or iterable input from pipeline",
342-
).with_label(
343-
format!(
344-
"requires string or iterable input; got {}",
345-
value.get_type(),
346-
),
347-
call.head,
348-
)
331+
PipelineData::Value(Value::String { val, .. }, _) => {
332+
Ok(Value::int(val.len() as i64, call.head).into_pipeline_data())
333+
},
334+
_ => Err(
335+
LabeledError::new(
336+
"Expected String or iterable input from pipeline",
337+
).with_label(
338+
format!(
339+
"requires string or iterable input; got {}",
340+
input.get_type(),
349341
),
350-
}
351-
}
342+
call.head,
343+
)
344+
),
352345
}
353346
}
354347
}

0 commit comments

Comments
 (0)