Skip to content

Commit b182cae

Browse files
committed
docs(stackable-versioned): Add section about hint(...)
1 parent 4dac3ab commit b182cae

File tree

1 file changed

+35
-0
lines changed
  • crates/stackable-versioned-macros/src

1 file changed

+35
-0
lines changed

crates/stackable-versioned-macros/src/lib.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,41 @@ mod utils;
645645
/// ```
646646
/// </details>
647647
///
648+
/// ## Additional Arguments
649+
///
650+
/// In addition to the field actions, the following top-level field arguments
651+
/// are available:
652+
///
653+
/// ### Hinting Wrapper Types
654+
///
655+
/// With `#[versioned(hint(...))]` it is possible to give hints to the macro
656+
/// that the field contains a wrapped type. Currently, these following hints
657+
/// are supported:
658+
///
659+
/// - `hint(option)`: Indicates that the field contains an `Option<T>`.
660+
/// - `hint(vec)`: Indicates that the field contains a `Vec<T>`.
661+
///
662+
/// These hints are especially useful for generated conversion functions. With
663+
/// these hints in place, the types are correctly mapped using `Into::into`.
664+
///
665+
/// ```
666+
/// # use stackable_versioned_macros::versioned;
667+
/// #[versioned(
668+
/// version(name = "v1alpha1"),
669+
/// version(name = "v1beta1")
670+
/// )]
671+
/// mod versioned {
672+
/// pub struct Foo {
673+
/// #[versioned(
674+
/// changed(since = "v1beta1", from_type = "Vec<usize>"),
675+
/// hint(vec)
676+
/// )]
677+
/// bar: Vec<usize>,
678+
/// baz: bool,
679+
/// }
680+
/// }
681+
/// ```
682+
///
648683
/// # Generated Helpers
649684
///
650685
/// This macro generates a few different helpers to enable different operations

0 commit comments

Comments
 (0)