#derive #ketos

macro ketos_derive

Derive traits for Ketos scripting language

4 releases (breaking)

0.12.0 Dec 25, 2019
0.11.0 Mar 24, 2019
0.10.0 Jun 3, 2017
0.1.0 Apr 23, 2017

#957 in Procedural macros

Download history 107/week @ 2022-10-07 48/week @ 2022-10-14 72/week @ 2022-10-21 41/week @ 2022-10-28 41/week @ 2022-11-04 97/week @ 2022-11-11 42/week @ 2022-11-18 15/week @ 2022-11-25 18/week @ 2022-12-02 38/week @ 2022-12-09 22/week @ 2022-12-16 41/week @ 2022-12-23 18/week @ 2022-12-30 21/week @ 2023-01-06 22/week @ 2023-01-13 41/week @ 2023-01-20

108 downloads per month
Used in 3 crates

MIT/Apache

21KB
357 lines

ketos_derive

Provides a set of custom #[derive(...)] macros for convenience when using Ketos.

One or more of the following names can be added to the derive attribute of any struct or enum value. For example:

extern crate ketos;

#[derive(Clone, Debug, ForeignValue, FromValue, IntoValue)]
struct Foo {
    // ...
}

derive(ForeignValue)

Implements ForeignValue for the given type. The only method implemented by this macro is type_name. All other methods retain their default implementations.

The ForeignValue trait must be implemented (either manually or using this derive) for any of the other derive implementations to succeed.

derive(FromValue)

Implements FromValue for the given type.

The generated implementation requires that the instance of the type held by the Ketos Value is unique, i.e. that the contained Rc has a reference count of 1.

If your type implements Clone, derive(FromValueClone) will instead generate an implementation of FromValue that clones the contained value, if necessary.

derive(FromValueClone)

Implements FromValue for the given type, provided that the type implements the Clone trait.

If the value contained in the Ketos Value is not unique, the result will be a clone of the contained value.

derive(FromValueRef)

Implements FromValueRef for the given type.

derive(IntoValue)

Implements Into<Value> for the given type.

Dependencies

~195–590KB
~14K SLoC