Skip to content

Commit f1abc77

Browse files
committed
Merge rust-bitcoin#3907: units: Fix ref_option clippy lint
29f1a46 Enable `ref_option` lint and allow individually (Jamil Lambert, PhD) Pull request description: The last `TODO` in rust-bitcoin#3825 Allow the `ref_option` lint in the cases where the lint wants us to change the API to ```use `Option<&T>` instead of `&Option<T>` ``` The other option would be to keep the lint as `allow` and add a comment to `Cargo.toml` as to why we are allowing it like the other cases that are allowed. Close rust-bitcoin#3825 ACKs for top commit: apoelstra: ACK 29f1a46; successfully ran local tests; nice! tcharding: ACK 29f1a46 Tree-SHA512: 181d617060e8ae0e75f033b1f356106fc89bdee9841085c889b775e82711c147e5282ecb0e3bf80cdb058034365bbfc7289c029ba0bf8b0b0f26d22505c63aa2
2 parents 6bc12e9 + 29f1a46 commit f1abc77

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

units/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ redundant_closure_for_method_calls = "warn"
129129
redundant_else = "warn"
130130
ref_as_ptr = "warn"
131131
ref_binding_to_reference = "warn"
132-
ref_option = "allow" # TODO: Still neds considering.
132+
ref_option = "warn"
133133
ref_option_ref = "warn"
134134
return_self_not_must_use = "warn"
135135
same_functions_in_if_condition = "warn"

units/src/amount/serde.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ pub mod as_sat {
207207
use super::private;
208208
use crate::amount::serde::SerdeAmountForOpt;
209209

210+
#[allow(clippy::ref_option)] // API forced by serde.
210211
pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
211212
a: &Option<A>,
212213
s: S,
@@ -277,6 +278,7 @@ pub mod as_btc {
277278
use super::private;
278279
use crate::amount::serde::SerdeAmountForOpt;
279280

281+
#[allow(clippy::ref_option)] // API forced by serde.
280282
pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
281283
a: &Option<A>,
282284
s: S,
@@ -347,6 +349,7 @@ pub mod as_str {
347349
use super::private;
348350
use crate::amount::serde::SerdeAmountForOpt;
349351

352+
#[allow(clippy::ref_option)] // API forced by serde.
350353
pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
351354
a: &Option<A>,
352355
s: S,

units/src/fee_rate/serde.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub mod as_sat_per_kwu {
5353

5454
use crate::FeeRate;
5555

56+
#[allow(clippy::ref_option)] // API forced by serde.
5657
pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
5758
match *f {
5859
Some(f) => s.serialize_some(&f.to_sat_per_kwu()),
@@ -124,6 +125,7 @@ pub mod as_sat_per_vb_floor {
124125
use crate::fee_rate::serde::OverflowError;
125126
use crate::fee_rate::FeeRate;
126127

128+
#[allow(clippy::ref_option)] // API forced by serde.
127129
pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
128130
match *f {
129131
Some(f) => s.serialize_some(&f.to_sat_per_vb_floor()),
@@ -199,6 +201,7 @@ pub mod as_sat_per_vb_ceil {
199201
use crate::fee_rate::serde::OverflowError;
200202
use crate::fee_rate::FeeRate;
201203

204+
#[allow(clippy::ref_option)] // API forced by serde.
202205
pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
203206
match *f {
204207
Some(f) => s.serialize_some(&f.to_sat_per_vb_ceil()),

0 commit comments

Comments
 (0)