Skip to content

Generic merge trait with implementations for basic types

Notifications You must be signed in to change notification settings

ekke-rs/ekke_merge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ekke_Merge

A general merge trait that can be derived on custom structs. I use it for merging user configuration into default configuration. In order to derive it automatically for a struct, all fields on the struct must implement Merge.

Merge comes with default impls for all primitive types and several std::collections (Vec, HashMap and BTreeMap). Vectors are not merged but replaced, because otherwise we don't have the possibility of removing entries, only adding. Therefor the impl for Vec uses mem::replace as for other types for which merging makes no sense.

Impls for serde_yaml are provided behind a feature ("serdeyaml"). This allows deserializing yaml configuration into your custom type, and make that type mergable.

TODO

  • change should_panic tests to verify the error type
  • add other collections from std
  • add impls for other formats than yaml
  • add a macro to generate for tuples of longer arity

About

Generic merge trait with implementations for basic types

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages