Skip to main content

define

Function define 

Source
pub fn define(options: KeyvalConfig<'_>) -> Result<()>
Expand description

(Re-)defines this Key of kind ‘kind’.

Defines a keyword key used in keyval arguments for the set keyset and, and if the option code is given, defines appropriate macros when used with the keyval package (or extensions thereof).

If type is given, it defines the type of value that must be supplied, such as Dimension. If default is given, that value will be used when key is used without an equals and explicit value in a keyvals argument.

A scope option can be given, which can be used to defined the key-value pair globally instead of in the current scope.

Several more options can be given. These implement the behaviour of the xkeyval package.

The prefix parameter can be used to configure a custom prefix for the macros to be defined. The kind parameter can be used to configure special types of xkeyval pairs.

The ‘ordinary’ kind behaves like a normal keyval parameter.

The ‘command’ kind defines a command key, that when run stores the value of the key in a special macro, which can be further specefied by the macroprefix option.

The ‘choice’ kind defines a choice key, which takes additional options choices (to specify which choices are valid values), mismatch (to be run if an invalid choice is made) and bin (see xkeyval documentation for details).

The ‘boolean’ kind defines a special choice key that takes possible values true and false, and defines a new Conditional according to the assumed value. The name of this conditional can be specified with the macroprefix option.

The kind parameter only takes effect when code is given, otherwise only meta-data is stored.