mirror of
https://github.com/nushell/nushell.git
synced 2025-06-30 22:50:14 +02:00
switch substring to bytes (#538)
* switch substring to bytes * Add a test
This commit is contained in:
@ -157,12 +157,18 @@ fn action(input: &Value, options: &Substring, head: Span) -> Value {
|
||||
Ordering::Less => Value::String {
|
||||
val: {
|
||||
if end == isize::max_value() {
|
||||
s.chars().skip(start as usize).collect::<String>()
|
||||
String::from_utf8_lossy(
|
||||
&s.bytes().skip(start as usize).collect::<Vec<_>>(),
|
||||
)
|
||||
.to_string()
|
||||
} else {
|
||||
s.chars()
|
||||
.skip(start as usize)
|
||||
.take((end - start) as usize)
|
||||
.collect::<String>()
|
||||
String::from_utf8_lossy(
|
||||
&s.bytes()
|
||||
.skip(start as usize)
|
||||
.take((end - start) as usize)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.to_string()
|
||||
}
|
||||
},
|
||||
span: head,
|
||||
|
Reference in New Issue
Block a user