macro_rules! empty_virtual_extension {
(
target: $target:ty,
tag: $extension:ty,
schema: static $schema:ty
$(, generics: [$($gen:tt),* $(,)? ])?
$(, bounds: [$($extra_bounds:tt)*])?
$(,)?
) => { ... };
(
target: $target:ty,
tag: $extension:ty,
schema: $schema:ty
$(, generics: [$($gen:tt),* $(,)? ])?
$(, bounds: [$($extra_bounds:tt)*])?
$(,)?
) => { ... };
}Expand description
Implements an empty virtual extension schema for a given extension.
This macro defines a no-op schema where the extension has no storage and behaves as absent.
It supports two modes:
-
Dynamic (default) -> implements
VirtualDynExtensionSchema- uses vector-like semantics (
Vec<()>) - size-related operations (
len,min,max) return0
- uses vector-like semantics (
-
Static (
statickeyword) -> implementsVirtualStaticExtensionSchema- uses array-like semantics (
[(); 0]) - fully determined at compile time
- no size-related operations are required
- uses array-like semantics (
§Semantics
In both modes:
None,Some, andReprare represented as()- no data is stored
- the extension is effectively non-existent
This is useful when:
- a container participates in the extension system
- but a particular extension is unsupported or intentionally omitted
§Syntax
§Dynamic (default)
ⓘ
empty_virtual_extension!(
target: MyContainer,
tag: MyExtension,
schema: MySchema,
generics: [T, U],
bounds: [T: Clone, U: Default],
);§Static
ⓘ
empty_virtual_extension!(
target: MyContainer,
tag: MyExtension,
schema: static MySchema,
);§Parameters
target: container type (conceptual owner of the extension)tag: discriminant identifying the extensionschema: schema type to implementgenerics(optional): generics for the implbounds(optional): additionalwhereconstraints
§Behavior
- The extension is treated as non-existent
- Dynamic mode:
- uses
Vec<()>(always empty) - returns
0for all size queries
- uses
- Static mode:
- uses
[(); 0](zero-length array) - fully resolved at compile time
- uses