Skip to content

Commit 0279802

Browse files
committed
Merge rust-bitcoin#3623: backport: Deprecate Amount::fmt_value_in
107acf3 backport: Deprecate Amount::fmt_value_in (Tobin C. Harding) Pull request description: We an use `Amount::display_in` now, this was done on master in PR rust-bitcoin#2951. ACKs for top commit: shinghim: ACK 107acf3 apoelstra: ACK 107acf3; successfully ran local tests Tree-SHA512: b46156415a281caad5cd3238921f70dd8f575d700b901583fcdd9e037f51dab348d44efb1a74b385252a37d677d7fd7369ec7b623b680585a9427f1d1c448fb0
2 parents a0ba637 + 107acf3 commit 0279802

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

units/src/amount.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ impl Amount {
987987
///
988988
/// Does not include the denomination.
989989
#[rustfmt::skip]
990+
#[deprecated(since = "0.1.3", note = "use `display_in()` instead")]
990991
pub fn fmt_value_in(self, f: &mut dyn fmt::Write, denom: Denomination) -> fmt::Result {
991992
fmt_satoshi_in(self.to_sat(), false, f, denom, false, FormatOptions::default())
992993
}
@@ -995,20 +996,13 @@ impl Amount {
995996
///
996997
/// Does not include the denomination.
997998
#[cfg(feature = "alloc")]
998-
pub fn to_string_in(self, denom: Denomination) -> String {
999-
let mut buf = String::new();
1000-
self.fmt_value_in(&mut buf, denom).unwrap();
1001-
buf
1002-
}
999+
pub fn to_string_in(self, denom: Denomination) -> String { self.display_in(denom).to_string() }
10031000

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

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

0 commit comments

Comments
 (0)