https://github.com/enzious/smart-serde-default
An annotation to implement #[serde(default)] and Default.
https://github.com/enzious/smart-serde-default
Last synced: 5 months ago
JSON representation
An annotation to implement #[serde(default)] and Default.
- Host: GitHub
- URL: https://github.com/enzious/smart-serde-default
- Owner: enzious
- License: apache-2.0
- Created: 2024-06-21T22:08:43.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-21T22:20:19.000Z (almost 2 years ago)
- Last Synced: 2026-01-06T13:50:25.724Z (5 months ago)
- Language: Rust
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE.md
Awesome Lists containing this project
README
# smart-serde-default
[](https://github.com/enzious/smart-serde-default/blob/master/LICENSE.md)
[](https://github.com/enzious/smart-serde-default/graphs/contributors)
[](https://github.com/smart-serde-default/smart-serde-default)
[](https://crates.io/crates/smart-serde-default)
A crate that basically extends the [serde-inline-default] and [smart-default]
crates functionality to allow you to specify a default for both
[std::default::Default] and [serde] with one annotation.
## Documentation
- [API Documentation](https://docs.rs/smart-serde-default)
## Defining defaults
```rust
#[smart_serde_default]
#[derive(Debug, Deserialize, Serialize, SmartDefault)]
pub struct FuzionRedisConfigBuilder {
#[smart_default(String::from("127.0.0.1"))]
host: String,
#[smart_default(6379)]
port: u16,
}
```
[serde-inline-default]: https://docs.rs/serde-inline-default
[smart-default]: https://docs.rs/smart-default
[serde]: https://docs.rs/serde
[std::default::Default]: https://doc.rust-lang.org/std/default/trait.Default.html