pub trait OptionDecl: 'static {
type Value: OptionType;
const NAME: &'static str;
const DOC: &'static str;
const CUSTOMIZABLE: bool = true;
// Required method
fn default_value() -> Self::Value;
// Provided method
fn type_id() -> TypeId
where Self: Sized { ... }
}Expand description
Compile-time declaration of one option. Each option type is a
unique unit struct (typically generated by the crate::options!
macro) implementing this trait.
Constants on the trait carry the metadata :set / TOML /
:describe-option need; the type itself carries the identity
(TypeId lookups for hot-path reads). The associated Value
type’s OptionType impl carries the parse / format / enumerate
machinery already in this crate.
'static bound: option types are zero-sized markers and have
no runtime data; the 'static lets us key registry storage
on TypeId.
Required Associated Constants§
Sourceconst NAME: &'static str
const NAME: &'static str
Public display name. Boundary-facing only – :set <NAME>=…,
TOML keys, completion candidates, :describe-option.
Internal access is type-driven. The macro derives this
from the option’s identifier (with namespace prefix when
declared via mode_options!); manually-typed NAMEs are
not supported for built-in options.
Provided Associated Constants§
Sourceconst CUSTOMIZABLE: bool = true
const CUSTOMIZABLE: bool = true
Customize-visibility flag. true (the default) ⇒ option
appears in :set autocomplete + the :customize group
view. false ⇒ plugin / engine-internal state, hidden
from user surfaces. Equivalent of emacs’s defvar vs
defcustom. (See mode-architecture.md §6.5.3.)
Required Associated Types§
Sourcetype Value: OptionType
type Value: OptionType
The runtime value type. bool, i64, String, plus any
domain enum that impls OptionType.
Required Methods§
Sourcefn default_value() -> Self::Value
fn default_value() -> Self::Value
Default value. Returned by a function (rather than a
const) so non-const-constructible types like String
can be defaults.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".