Skip to content

Commit

Permalink
backport: Deprecate Amount::fmt_value_in
Browse files Browse the repository at this point in the history
We an use `Amount::display_in` now, this was done on master in PR rust-bitcoin#2951.
  • Loading branch information
tcharding committed Nov 14, 2024
1 parent a0ba637 commit 107acf3
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions units/src/amount.rs
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,7 @@ impl Amount {
///
/// Does not include the denomination.
#[rustfmt::skip]
#[deprecated(since = "0.1.3", note = "use `display_in()` instead")]
pub fn fmt_value_in(self, f: &mut dyn fmt::Write, denom: Denomination) -> fmt::Result {
fmt_satoshi_in(self.to_sat(), false, f, denom, false, FormatOptions::default())
}
Expand All @@ -995,20 +996,13 @@ impl Amount {
///
/// Does not include the denomination.
#[cfg(feature = "alloc")]
pub fn to_string_in(self, denom: Denomination) -> String {
let mut buf = String::new();
self.fmt_value_in(&mut buf, denom).unwrap();
buf
}
pub fn to_string_in(self, denom: Denomination) -> String { self.display_in(denom).to_string() }

/// Get a formatted string of this [Amount] in the given denomination,
/// suffixed with the abbreviation for the denomination.
#[cfg(feature = "alloc")]
pub fn to_string_with_denomination(self, denom: Denomination) -> String {
let mut buf = String::new();
self.fmt_value_in(&mut buf, denom).unwrap();
write!(buf, " {}", denom).unwrap();
buf
self.display_in(denom).show_denomination().to_string()
}

// Some arithmetic that doesn't fit in `core::ops` traits.
Expand Down

0 comments on commit 107acf3

Please sign in to comment.