This commit is contained in:
Tim 'Piepmatz' Hesse 2024-06-03 00:50:31 +02:00
parent d7fc6339a2
commit 628382283e
2 changed files with 15 additions and 15 deletions

View File

@ -13,15 +13,15 @@ use std::{
}; };
/// A trait for loading a value from a [`Value`]. /// A trait for loading a value from a [`Value`].
/// ///
/// # Derivable /// # Derivable
/// This trait can be used with `#[derive]`. /// This trait can be used with `#[derive]`.
/// When derived on structs with named fields, it expects a [`Value::Record`] /// When derived on structs with named fields, it expects a [`Value::Record`]
/// where each field of the struct maps to a corresponding field in the record. /// where each field of the struct maps to a corresponding field in the record.
/// For structs with unnamed fields, it expects a [`Value::List`], and the /// For structs with unnamed fields, it expects a [`Value::List`], and the
/// fields are populated in the order they appear in the list. /// fields are populated in the order they appear in the list.
/// Unit structs expect a [`Value::Nothing`], as they contain no data. /// Unit structs expect a [`Value::Nothing`], as they contain no data.
/// Attempting to convert from a non-matching `Value` type will result in an /// Attempting to convert from a non-matching `Value` type will result in an
/// error. /// error.
// TODO: explain derive for enums // TODO: explain derive for enums
pub trait FromValue: Sized { pub trait FromValue: Sized {

View File

@ -5,15 +5,15 @@ use crate::{Record, ShellError, Span, Value};
/// A trait for converting a value into a [`Value`]. /// A trait for converting a value into a [`Value`].
/// ///
/// This conversion is infallible, for fallible conversions use [`TryIntoValue`]. /// This conversion is infallible, for fallible conversions use [`TryIntoValue`].
/// ///
/// # Derivable /// # Derivable
/// This trait can be used with `#[derive]`. /// This trait can be used with `#[derive]`.
/// When derived on structs with named fields, the resulting value /// When derived on structs with named fields, the resulting value
/// representation will use [`Value::Record`], where each field of the record /// representation will use [`Value::Record`], where each field of the record
/// corresponds to a field of the struct. /// corresponds to a field of the struct.
/// For structs with unnamed fields, the value representation will be /// For structs with unnamed fields, the value representation will be
/// [`Value::List`], with all fields inserted into a list. /// [`Value::List`], with all fields inserted into a list.
/// Unit structs will be represented as [`Value::Nothing`] since they contain /// Unit structs will be represented as [`Value::Nothing`] since they contain
/// no data. /// no data.
// TODO: explain derive for enums // TODO: explain derive for enums
pub trait IntoValue: Sized { pub trait IntoValue: Sized {