Skip to content

oxidecomputer/partial-struct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

partial-struct

Create subsets of structs

A macro (for structs) that generates a new struct containing a subset of the fields of the tagged struct. New structs can have derive values added or removed. Any subsequent (non-partial) derives or macros will be applied to the new structs.

Example

use partial_struct::partial;

///
// Using all of the macro features
///
#[partial(NewStruct, with(Debug), without(Default))]
#[derive(Default)]
struct OldStruct {
    a: u32,
    #[partial(NewStruct(skip))]
    b: u32,
    #[partial(NewStruct(retype = u32))]
    c: u8,
}

will generate

#[derive(Default)]
struct OldStruct {
   a: u32,
   b: u32,
   c: u8,
}

#[derive(Debug)]
struct NewStruct {
   a: u32,
   c: u32,
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages