Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jordens committed Oct 1, 2024
1 parent 95b8596 commit 2a6907a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
4 changes: 1 addition & 3 deletions miniconf/src/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ pub fn get_by_key<T: TreeSerialize<Y> + ?Sized, const Y: usize, K: IntoKeys>(
tree: &T,
keys: K,
data: &mut [u8],
) -> Result<usize, Error<ser::Error>>
where
{
) -> Result<usize, Error<ser::Error>> {
let mut ser = ser::Serializer::new(data);
tree.serialize_by_key(keys.into_keys(), &mut ser)?;
Ok(ser.end())
Expand Down
14 changes: 9 additions & 5 deletions miniconf_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ mod field;
mod tree;
use tree::Tree;

/// Derive the `TreeKey` trait for a struct.
/// Derive the `TreeKey` trait for a struct or enum.
///
/// This also derives `KeyLookup` if necessary.
#[proc_macro_derive(TreeKey, attributes(tree))]
pub fn derive_tree_key(input: TokenStream) -> TokenStream {
match Tree::from_derive_input(&parse_macro_input!(input as DeriveInput)) {
Expand All @@ -16,7 +18,7 @@ pub fn derive_tree_key(input: TokenStream) -> TokenStream {
.into()
}

/// Derive the `TreeSerialize` trait for a struct.
/// Derive the `TreeSerialize` trait for a struct or enum.
#[proc_macro_derive(TreeSerialize, attributes(tree))]
pub fn derive_tree_serialize(input: TokenStream) -> TokenStream {
match Tree::from_derive_input(&parse_macro_input!(input as DeriveInput)) {
Expand All @@ -26,7 +28,7 @@ pub fn derive_tree_serialize(input: TokenStream) -> TokenStream {
.into()
}

/// Derive the `TreeDeserialize` trait for a struct.
/// Derive the `TreeDeserialize` trait for a struct or enum.
#[proc_macro_derive(TreeDeserialize, attributes(tree))]
pub fn derive_tree_deserialize(input: TokenStream) -> TokenStream {
match Tree::from_derive_input(&parse_macro_input!(input as DeriveInput)) {
Expand All @@ -36,7 +38,7 @@ pub fn derive_tree_deserialize(input: TokenStream) -> TokenStream {
.into()
}

/// Derive the `TreeAny` trait for a struct.
/// Derive the `TreeAny` trait for a struct or enum.
#[proc_macro_derive(TreeAny, attributes(tree))]
pub fn derive_tree_any(input: TokenStream) -> TokenStream {
match Tree::from_derive_input(&parse_macro_input!(input as DeriveInput)) {
Expand All @@ -46,7 +48,9 @@ pub fn derive_tree_any(input: TokenStream) -> TokenStream {
.into()
}

/// Shorthand to derive the `TreeKey`, `TreeAny`, `TreeSerialize`, and `TreeDeserialize` traits for a struct.
/// Derive the `TreeKey`, `TreeSerialize`, `TreeDeserialize`, and `TreeAny` traits for a struct or enum.
///
/// This is a shorthand to derive multiple traits.
#[proc_macro_derive(Tree, attributes(tree))]
pub fn derive_tree(input: TokenStream) -> TokenStream {
match Tree::from_derive_input(&parse_macro_input!(input as DeriveInput)) {
Expand Down

0 comments on commit 2a6907a

Please sign in to comment.