This commit is contained in:
Andras Schmelczer 2025-12-06 11:50:18 +00:00
parent 20eb81a78d
commit 25d9ab34d5

View file

@ -1,5 +1,4 @@
use std::borrow::Cow;
use std::fmt::Debug;
use std::{borrow::Cow, fmt::Debug};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
@ -59,27 +58,19 @@ impl From<NumberOrString> for JsValue {
}
impl From<i64> for NumberOrString {
fn from(value: i64) -> Self {
NumberOrString::Number(value)
}
fn from(value: i64) -> Self { NumberOrString::Number(value) }
}
impl From<String> for NumberOrString {
fn from(value: String) -> Self {
NumberOrString::Text(value)
}
fn from(value: String) -> Self { NumberOrString::Text(value) }
}
impl From<&str> for NumberOrString {
fn from(value: &str) -> Self {
NumberOrString::Text(value.to_string())
}
fn from(value: &str) -> Self { NumberOrString::Text(value.to_owned()) }
}
impl<'a> From<Cow<'a, str>> for NumberOrString {
fn from(value: Cow<'a, str>) -> Self {
NumberOrString::Text(value.into_owned())
}
fn from(value: Cow<'a, str>) -> Self { NumberOrString::Text(value.into_owned()) }
}
/// Error type for deserialisation failures
@ -110,7 +101,5 @@ impl std::error::Error for DeserialisationError {}
#[cfg(feature = "wasm")]
impl From<DeserialisationError> for JsValue {
fn from(error: DeserialisationError) -> Self {
JsValue::from_str(&error.message)
}
fn from(error: DeserialisationError) -> Self { JsValue::from_str(&error.message) }
}