Skip to content

Commit fef57c8

Browse files
Techassiadwk67
andauthored
docs(stackable-versioned): Add section about hint(...) (#1128)
* docs(stackable-versioned): Add section about hint(...) * docs(versioned): Adjust #[versioned(hint)] wording Co-authored-by: Andrew Kenworthy <[email protected]> --------- Co-authored-by: Andrew Kenworthy <[email protected]>
1 parent 85ff69e commit fef57c8

File tree

1 file changed

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

1 file changed

+31
-0
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,37 @@ mod utils;
618618
/// ```
619619
/// </details>
620620
///
621+
/// ## Additional Arguments
622+
///
623+
/// In addition to the field actions, the following top-level field arguments
624+
/// are available:
625+
///
626+
/// ### Hinting Wrapper Types
627+
///
628+
/// With `#[versioned(hint(...))]` it is possible to give hints to the macro
629+
/// that the field contains a wrapped type. Currently, these following hints
630+
/// are supported:
631+
///
632+
/// - `hint(option)`: Indicates that the field contains an `Option<T>`.
633+
/// - `hint(vec)`: Indicates that the field contains a `Vec<T>`.
634+
///
635+
/// These hints are especially useful for generated conversion functions. With
636+
/// these hints in place, the types are correctly mapped using `Into::into`
637+
/// (assuming the necessary `From` trait methods are implemented on the target
638+
/// types for the conversion to be done correctly).
639+
///
640+
/// ```
641+
/// # use stackable_versioned_macros::versioned;
642+
/// #[versioned(version(name = "v1alpha1"), version(name = "v1beta1"))]
643+
/// mod versioned {
644+
/// pub struct Foo {
645+
/// #[versioned(changed(since = "v1beta1", from_type = "Vec<usize>"), hint(vec))]
646+
/// bar: Vec<usize>,
647+
/// baz: bool,
648+
/// }
649+
/// }
650+
/// ```
651+
///
621652
/// # Generated Helpers
622653
///
623654
/// This macro generates a few different helpers to enable different operations

0 commit comments

Comments
 (0)