use std::sync::Arc;
use crate::{GcValue, Map};
impl From<&str> for GcValue {
fn from(value: &str) -> Self {
Self::new_text(value)
}
}
impl From<String> for GcValue {
fn from(value: String) -> Self {
Self::new_text(value)
}
}
impl From<Arc<str>> for GcValue {
fn from(value: Arc<str>) -> Self {
Self::new_text(value)
}
}
impl From<i8> for GcValue {
fn from(value: i8) -> Self {
Self::new_int(value)
}
}
impl From<i16> for GcValue {
fn from(value: i16) -> Self {
Self::new_int(value)
}
}
impl From<i32> for GcValue {
fn from(value: i32) -> Self {
Self::new_int(value)
}
}
impl From<i64> for GcValue {
fn from(value: i64) -> Self {
Self::new_int(value)
}
}
impl From<i128> for GcValue {
fn from(value: i128) -> Self {
Self::new_int(value)
}
}
impl From<isize> for GcValue {
fn from(value: isize) -> Self {
Self::new_int(value as i128)
}
}
impl From<u8> for GcValue {
fn from(value: u8) -> Self {
Self::new_int(value)
}
}
impl From<u16> for GcValue {
fn from(value: u16) -> Self {
Self::new_int(value)
}
}
impl From<u32> for GcValue {
fn from(value: u32) -> Self {
Self::new_int(value)
}
}
impl From<u64> for GcValue {
fn from(value: u64) -> Self {
Self::new_int(value)
}
}
impl From<usize> for GcValue {
fn from(value: usize) -> Self {
Self::new_int(value as i128)
}
}
impl From<f32> for GcValue {
fn from(value: f32) -> Self {
Self::new_float(value)
}
}
impl From<f64> for GcValue {
fn from(value: f64) -> Self {
Self::new_float(value)
}
}
impl From<bool> for GcValue {
fn from(value: bool) -> Self {
Self::new_boolean(value)
}
}
impl From<Arc<[GcValue]>> for GcValue {
fn from(value: Arc<[GcValue]>) -> Self {
Self::new_array(value)
}
}
impl From<Vec<GcValue>> for GcValue {
fn from(value: Vec<GcValue>) -> Self {
Self::new_array(value)
}
}
impl From<&[GcValue]> for GcValue {
fn from(value: &[GcValue]) -> Self {
Self::new_array(value)
}
}
impl From<Arc<Map>> for GcValue {
fn from(value: Arc<Map>) -> Self {
Self::new_map(value)
}
}
impl From<Arc<(GcValue, GcValue)>> for GcValue {
fn from(value: Arc<(GcValue, GcValue)>) -> Self {
Self::new_tag(value)
}
}
impl From<Arc<[u8]>> for GcValue {
fn from(value: Arc<[u8]>) -> Self {
Self::new_bytes(value)
}
}
impl<const N: usize> From<&[u8; N]> for GcValue {
fn from(value: &[u8; N]) -> Self {
Self::new_bytes(&value[..])
}
}
impl From<()> for GcValue {
fn from(_: ()) -> Self {
Self::new_null()
}
}
impl FromIterator<GcValue> for GcValue {
fn from_iter<T: IntoIterator<Item = GcValue>>(iter: T) -> Self {
Self::collect_array(iter)
}
}
impl FromIterator<(GcValue, GcValue)> for GcValue {
fn from_iter<T: IntoIterator<Item = (GcValue, GcValue)>>(iter: T) -> Self {
Self::collect_map(iter)
}
}
impl FromIterator<u8> for GcValue {
fn from_iter<T: IntoIterator<Item = u8>>(iter: T) -> Self {
Self::collect_bytes(iter)
}
}