Merge rust-bitcoin/rust-bitcoin#2207: policy: Add section on standard set of derives

cb42c74f58 policy: Add section on standard set of derives (Tobin C. Harding)
ec1a5a25c7 CONTRIBUTING: Remove stale links (Tobin C. Harding)

Pull request description:

  We can have a standard set of derives to make it easier for new devs to work out what to use and also to help us move towards a uniform set in preparation for crate stabilization.

  This is not me imposing my view but rather a place for the discussion to happen, could have been a discussions topic also? Using "open" instead of "draft" to aid visibility. Probably requires more than the usual amount of acks.

ACKs for top commit:
  apoelstra:
    ACK cb42c74f58
  Kixunil:
    ACK cb42c74f58

Tree-SHA512: b4c4094ea3652e92a5bea90e16f13971202710166524cc15abef5e8318ba5f59df084f5246331870fc641456b49d4e35d266c937375bdc5035f03699a7d4c1b9
This commit is contained in:
Andrew Poelstra 2023-12-15 22:40:31 +00:00
commit eadc6a6c9e
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
1 changed files with 21 additions and 2 deletions

View File

@ -18,8 +18,6 @@ changes to this document in a pull request.
* [Peer review](#peer-review) * [Peer review](#peer-review)
* [Repository maintainers](#repository-maintainers) * [Repository maintainers](#repository-maintainers)
- [Coding conventions](#coding-conventions) - [Coding conventions](#coding-conventions)
* [Formatting](#formatting)
* [MSRV](#msrv)
* [Naming conventions](#naming-conventions) * [Naming conventions](#naming-conventions)
* [Upgrading dependencies](#upgrading-dependencies) * [Upgrading dependencies](#upgrading-dependencies)
* [Unsafe code](#unsafe-code) * [Unsafe code](#unsafe-code)
@ -380,6 +378,27 @@ sure, feel free to ask. If we determine panicking is more practical it must be d
panics that could theoretically occur because of bugs in our code must not be documented. panics that could theoretically occur because of bugs in our code must not be documented.
#### Derives
We try to use standard set of derives if it makes sense:
```
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
enum Foo {
Bar,
Baz,
}
```
For types that do should not form a total or partial order, or that technically do but it does not
make sense to compare them, we use the `Ordered` trait from the
[`ordered`](https://crates.io/crates/ordered) crate. See `absolute::LockTime` for an example.
For error types you likely want to use `#[derive(Debug, Clone, PartialEq, Eq)]`.
See [Errors](#errors) section.
#### Attributes #### Attributes
- `#[track_caller]`: Used on functions that panic on invalid arguments - `#[track_caller]`: Used on functions that panic on invalid arguments