Merge rust-bitcoin/rust-bitcoin#3907: units: Fix `ref_option` clippy lint

29f1a4613a Enable `ref_option` lint and allow individually (Jamil Lambert, PhD)

Pull request description:

  The last `TODO` in #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 #3825

ACKs for top commit:
  apoelstra:
    ACK 29f1a4613a090cd23baded1ef577aa4e3da8d33f; successfully ran local tests; nice!
  tcharding:
    ACK 29f1a4613a

Tree-SHA512: 181d617060e8ae0e75f033b1f356106fc89bdee9841085c889b775e82711c147e5282ecb0e3bf80cdb058034365bbfc7289c029ba0bf8b0b0f26d22505c63aa2
This commit is contained in:
merge-script 2025-01-16 02:22:06 +00:00
commit f1abc779f5
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
3 changed files with 7 additions and 1 deletions

View File

@ -129,7 +129,7 @@ redundant_closure_for_method_calls = "warn"
redundant_else = "warn"
ref_as_ptr = "warn"
ref_binding_to_reference = "warn"
ref_option = "allow" # TODO: Still neds considering.
ref_option = "warn"
ref_option_ref = "warn"
return_self_not_must_use = "warn"
same_functions_in_if_condition = "warn"

View File

@ -207,6 +207,7 @@ pub mod as_sat {
use super::private;
use crate::amount::serde::SerdeAmountForOpt;
#[allow(clippy::ref_option)] // API forced by serde.
pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
a: &Option<A>,
s: S,
@ -277,6 +278,7 @@ pub mod as_btc {
use super::private;
use crate::amount::serde::SerdeAmountForOpt;
#[allow(clippy::ref_option)] // API forced by serde.
pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
a: &Option<A>,
s: S,
@ -347,6 +349,7 @@ pub mod as_str {
use super::private;
use crate::amount::serde::SerdeAmountForOpt;
#[allow(clippy::ref_option)] // API forced by serde.
pub fn serialize<A: SerdeAmountForOpt, S: Serializer>(
a: &Option<A>,
s: S,

View File

@ -53,6 +53,7 @@ pub mod as_sat_per_kwu {
use crate::FeeRate;
#[allow(clippy::ref_option)] // API forced by serde.
pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
match *f {
Some(f) => s.serialize_some(&f.to_sat_per_kwu()),
@ -124,6 +125,7 @@ pub mod as_sat_per_vb_floor {
use crate::fee_rate::serde::OverflowError;
use crate::fee_rate::FeeRate;
#[allow(clippy::ref_option)] // API forced by serde.
pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
match *f {
Some(f) => s.serialize_some(&f.to_sat_per_vb_floor()),
@ -199,6 +201,7 @@ pub mod as_sat_per_vb_ceil {
use crate::fee_rate::serde::OverflowError;
use crate::fee_rate::FeeRate;
#[allow(clippy::ref_option)] // API forced by serde.
pub fn serialize<S: Serializer>(f: &Option<FeeRate>, s: S) -> Result<S::Ok, S::Error> {
match *f {
Some(f) => s.serialize_some(&f.to_sat_per_vb_ceil()),