mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Add Destruct macro and trait for automatically acessing struct fields
This commit is contained in:
@@ -16,6 +16,7 @@ pub struct NodeMetadata {
|
||||
pub description: &'static str,
|
||||
pub properties: Option<&'static str>,
|
||||
pub context_features: Vec<ContextFeature>,
|
||||
pub output_fields: &'static [StructField],
|
||||
}
|
||||
|
||||
// Translation struct between macro and definition
|
||||
@@ -36,6 +37,26 @@ pub struct FieldMetadata {
|
||||
pub unit: Option<&'static str>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct StructField {
|
||||
pub name: &'static str,
|
||||
pub node_path: &'static str,
|
||||
pub ty: Type,
|
||||
}
|
||||
|
||||
pub trait Destruct {
|
||||
fn fields(&self) -> &'static [StructField];
|
||||
}
|
||||
|
||||
impl<T> Destruct for &T
|
||||
where
|
||||
T: Default,
|
||||
{
|
||||
fn fields(&self) -> &'static [StructField] {
|
||||
&[]
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum RegistryWidgetOverride {
|
||||
None,
|
||||
|
||||
Reference in New Issue
Block a user