| Crates.io | value-extra |
| lib.rs | value-extra |
| version | 0.1.1 |
| created_at | 2026-01-16 14:24:32.763737+00 |
| updated_at | 2026-01-16 14:24:32.763737+00 |
| description | A tri-state Patch |
| homepage | |
| repository | https://github.com/itsfoxstudio/value-extra |
| max_upload_size | |
| id | 2048679 |
| size | 49,452 |
Extended value types for Rust — practical primitives beyond the standard library.
[dependencies]
value-extra = "0.1"
# With serde support
value-extra = { version = "0.1", features = ["serde"] }
Patch<T>A tri-state type for partial update semantics — distinguishing between "has value", "absent", and "explicitly null".
When handling partial updates (PATCH requests, config merging, etc.), Option<T> conflates two distinct states:
Patch<T> provides three states:
| JSON Input | Patch State | Meaning |
|---|---|---|
{ "name": "Alice" } |
Patch::Some("Alice") |
Set to value |
{ "name": null } |
Patch::None |
Explicitly clear |
{ } |
Patch::Empty |
Leave unchanged |
use value_extra::Patch;
fn apply_name_patch(current: &mut Option<String>, patch: Patch<String>) {
match patch {
Patch::Some(new) => *current = Some(new),
Patch::None => *current = None, // explicitly clear
Patch::Empty => {} // no change
}
}
map, and_then, unwrap_or, filter, zip, and moreSee the full documentation for API details and serde usage examples.
MIT — see LICENSE for details.