roopert
Roopert is an open-source toolkit for object-oriented programming patterns. Spend less time writing boilerplate and more time implementing functionality!
Attributes
| parent | extends | accessors | get | set |
|---|
parent
A field-level attribute for indicating which field is the parent of the struct in conjunction with the extends attribute macro.
This attribute macro takes no other parameters.
The standard form #[roopert(parent)] as well as a shortened form #[parent] macros may be used.
The extends attribute will automatically resolve types to fields, but the parent attribute overrides the default behaviour.
extends
A struct-level attribute for making a named struct "extend" functionality of another Rust type.
Rust types are supplied as parameters to indicate which type(s) the struct extends.
A field with the same type must also be in the struct.
The standard form #[roopert(extends)] attribute macro is used, and the #[roopert(parent)] attribute can be used on a field to explicitly declare the parent.
Extends or inheritance-like behaviour is accomplished by an automatic implementation of AsRef, AsMut, Into, Deref and DerefMut for the struct this attribute is applied to.
This creates smart-pointer behaviour along with the ability to explicitly downcast.
// automatically generated AsRef implementation by Roopert
// (not shown: AsMut, Into, Deref, and DerefMut implementations)
accessors
A struct-level attribute for automatically creating getters and setters for fields of a named struct.
Optionally, this attribute accepts one or two parameters (in any order): get = rule and set = rule,
where rule can be one of All (generate all accessors), Private (generate accessors for all private fields), No (don't generate -- default).
Additionally, the get and set attribute types can be used to override the struct-level getter and setter rule, respectively.
// automatically generated by Roopert
get
A field-level attribute for overriding accessors attribute behaviour for getters methods.
Optionally, pre = operation can be supplied to do an operation before the get function returns.
The optional parameter mutable = true can be supplied to get a mutable reference (as well as allow mutable self operations with the pre parameter).
The standard form #[roopert(get)] or the shortened #[get] attribute macro may be used.
Note: this doesn't work without #[roopert(accessors)] on the struct.
// automatically generated by Roopert
set
A field-level attribute for overriding accessors attribute behaviour for setter methods.
Optionally, pre = operation and post = operation can be used to do an operation before and after the variable is set, respectively.
The standard form #[roopert(set)] or shortened the #[set] attribute macro may be used.
Note: this doesn't work without #[roopert(accessors)] on the struct.
// automatically generated by Roopert
License: MIT