# conflate
The `conflate` crate provides the `Merge` trait that can be used to merge
multiple values into one.
## Contact
You can ask questions in the
[Discussions](https://github.com/rustic-rs/rustic/discussions) or have a look at
the [FAQ](https://rustic.cli.rs/docs/FAQ.html).
| Contact | Where? |
| ------------- | --------------------------------------------------------------------------------------------------------------- |
| Issue Tracker | [GitHub Issues](https://github.com/rustic-rs/conflate/issues/choose) |
| Discord | [![Discord](https://dcbadge.vercel.app/api/server/WRUWENZnzQ?style=flat-square)](https://discord.gg/WRUWENZnzQ) |
| Discussions | [GitHub Discussions](https://github.com/rustic-rs/rustic/discussions) |
## Usage
```rust
trait Merge {
fn merge(&mut self, other: Self);
}
```
`Merge` can be derived for structs:
```rust
use conflate::Merge;
#[derive(Merge)]
struct User {
// Fields with the skip attribute are skipped by Merge
#[merge(skip)]
pub name: &'static str,
// The strategy attribute is used to select the merge behavior
#[merge(strategy = conflate::option::overwrite_none)]
pub location: Option<&'static str>,
#[merge(strategy = conflate::vec::append)]
pub groups: Vec<&'static str>,
}
fn main() {
let defaults = User {
name: "",
location: Some("Internet"),
groups: vec!["rust"],
};
let mut ferris = User {
name: "Ferris",
location: None,
groups: vec!["mascot"],
};
ferris.merge(defaults);
assert_eq!("Ferris", ferris.name);
assert_eq!(Some("Internet"), ferris.location);
assert_eq!(vec!["mascot", "rust"], ferris.groups);
}
```
A merge strategy is a function with the signature
`fn merge