mirror of
https://github.com/nushell/nushell
synced 2025-01-28 04:45:18 +00:00
Update mode.rs
trying a switch to native endian
This commit is contained in:
parent
47ebde4087
commit
d23929fc80
1 changed files with 8 additions and 8 deletions
|
@ -90,15 +90,15 @@ pub fn mode(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||||
let hashable_values: Result<Vec<HashableType>, ShellError> = values
|
let hashable_values: Result<Vec<HashableType>, ShellError> = values
|
||||||
.iter()
|
.iter()
|
||||||
.map(|val| match val {
|
.map(|val| match val {
|
||||||
Value::Int { val, .. } => Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Int)),
|
Value::Int { val, .. } => Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Int)),
|
||||||
Value::Duration { val, .. } => {
|
Value::Duration { val, .. } => {
|
||||||
Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Duration))
|
Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Duration))
|
||||||
}
|
}
|
||||||
Value::Float { val, .. } => {
|
Value::Float { val, .. } => {
|
||||||
Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Float))
|
Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Float))
|
||||||
}
|
}
|
||||||
Value::Filesize { val, .. } => {
|
Value::Filesize { val, .. } => {
|
||||||
Ok(HashableType::new(val.to_be_bytes(), NumberTypes::Filesize))
|
Ok(HashableType::new(val.to_ne_bytes(), NumberTypes::Filesize))
|
||||||
}
|
}
|
||||||
other => Err(ShellError::UnsupportedInput(
|
other => Err(ShellError::UnsupportedInput(
|
||||||
"Unable to give a result with this input".to_string(),
|
"Unable to give a result with this input".to_string(),
|
||||||
|
@ -143,19 +143,19 @@ fn recreate_value(hashable_value: &HashableType, head: Span) -> Value {
|
||||||
let bytes = hashable_value.bytes;
|
let bytes = hashable_value.bytes;
|
||||||
match &hashable_value.original_type {
|
match &hashable_value.original_type {
|
||||||
NumberTypes::Int => Value::Int {
|
NumberTypes::Int => Value::Int {
|
||||||
val: i64::from_be_bytes(bytes),
|
val: i64::from_ne_bytes(bytes),
|
||||||
span: head,
|
span: head,
|
||||||
},
|
},
|
||||||
NumberTypes::Float => Value::Float {
|
NumberTypes::Float => Value::Float {
|
||||||
val: f64::from_be_bytes(bytes),
|
val: f64::from_ne_bytes(bytes),
|
||||||
span: head,
|
span: head,
|
||||||
},
|
},
|
||||||
NumberTypes::Duration => Value::Duration {
|
NumberTypes::Duration => Value::Duration {
|
||||||
val: i64::from_be_bytes(bytes),
|
val: i64::from_ne_bytes(bytes),
|
||||||
span: head,
|
span: head,
|
||||||
},
|
},
|
||||||
NumberTypes::Filesize => Value::Filesize {
|
NumberTypes::Filesize => Value::Filesize {
|
||||||
val: i64::from_be_bytes(bytes),
|
val: i64::from_ne_bytes(bytes),
|
||||||
span: head,
|
span: head,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue