rust-bitcoin/rust-bitcoin
docs: Ideas for documenting `units 1.0.0`
Aberta
#4.694 aberto em 8 de jul. de 2025
1.0-wantedC-unitsdochelp wanted
Métricas do repositório
- Stars
- (2.651 estrelas)
- Métricas de merge de PR
- (Mesclagem média 6d 21h) (115 fundiu PRs em 30d)
Description
Issue to track potential ideas for the cookbook relating to units v1.0.0.
When we created the cookbook we decided to put a file in crate/examples then add the same code to the cookbook - this still seems like a good idea to me.
So this issue relates to creating files in units/examples/ then creating cookbook entries also with the same code.
Amount
- Explain/justify the 'MAX = 21 million' decision
- Demo parsing strings and formatting
- Showcase basic best practices using
NumOpResult(probably leave complex math to theNumOpResultsection)
NumOpResult
This type is unusual, could do with thorough explanation. Including but not limited to:
- An explanation of why we added the type (i.e., why not just use
Result) - How to chain math ops e.g,
a + b - c - How to check the error type if combination fails and how to tell which operation failed
- How to sum using iterators
let amounts = [sat(42), sat(1337), sat(21)];
let sum = amounts.into_iter().map(|amount| NumOpResult::from(amount)).sum::<NumOpResult<Amount>>().unwrap();
assert_eq!(sum, sat(1400));
Calculating fees
Write a section explaining the relationship between weight, amount, and fee rate. Demo the API.
Lock times
Ouch, you know what to do.