[BREAKGLASS] Provides PartialDefault, a Rust trait similar to Default but with fewer guarantees
Go to file
Jordan Rose dbf69664b9
Some checks failed
CI / Tests (1.69.0) (push) Has been cancelled
CI / Tests (nightly) (push) Has been cancelled
CI / Lints (push) Has been cancelled
Fix GitHub CI
2023-10-25 16:37:06 -07:00
.github/workflows Fix GitHub CI 2023-10-25 16:37:06 -07:00
derive Initial version of PartialDefault 2023-10-25 12:24:14 -07:00
src Initial version of PartialDefault 2023-10-25 12:24:14 -07:00
.gitignore Initial version of PartialDefault 2023-10-25 12:24:14 -07:00
Cargo.toml Initial version of PartialDefault 2023-10-25 12:24:14 -07:00
LICENSE Add LICENSE file to go with Cargo.toml's license 2023-10-25 16:34:27 -07:00
README.md Initial version of PartialDefault 2023-10-25 12:24:14 -07:00

[PartialDefault] is a trait for giving a type a non-useful default value.

The standard Default trait documents its purpose as providing a "useful" default value. However, some types (such as a Credential) don't have meaningful defaults, and yet there are still uses for a known-initialized value:

PartialDefault satisfies this niche. A type that implements PartialDefault can provide a value that is safe to drop or assign over, but promises nothing else about that value. It provides a derive macro (opt-in, with the derive feature) and is no_std compatible.

License and Contributions

PartialDefault was made to support libsignal, but is available for general use under the AGPLv3. Still, this is meant to be a low-maintenance crate; do not expect active support or progress on feature requests.

Signal does accept external contributions to this project; however, signing a CLA (Contributor License Agreement) is required for all contributions.

Copyright 2023 Signal Messenger, LLC.

The partial-default-derive crate contains code adapted from the rust-smart-default crate, Copyright (c) 2017 Idan Arye, under the MIT license.