Merge rust-bitcoin/rust-bitcoin#1596: Implement fmt traits for ScriptBuf
ed6f6d11dd
Implement fmt traits for ScriptBuf (Tobin C. Harding) Pull request description: We can improve ergonomics of the `script` module by implementing the `fmt` traits on `ScriptBuf`, trivial because we can call through to the `Script` implementations. Fix: #1585 ACKs for top commit: Kixunil: ACKed6f6d11dd
apoelstra: ACKed6f6d11dd
Tree-SHA512: 878a1522af4ed1e10d1d8d60d150e6571008c008b5e5c662c67462f9e09075b4f1fe4e399ed50e98cd7253b6815937c6732cd1ce02b74a5be017d5b8fcdbbd2f
This commit is contained in:
commit
ca902e65f8
|
@ -691,6 +691,27 @@ impl core::str::FromStr for ScriptBuf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for ScriptBuf {
|
||||||
|
#[inline]
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::Display::fmt(self.as_script(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::LowerHex for ScriptBuf {
|
||||||
|
#[inline]
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::LowerHex::fmt(self.as_script(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::UpperHex for ScriptBuf {
|
||||||
|
#[inline]
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
fmt::UpperHex::fmt(self.as_script(), f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An object which can be used to construct a script piece by piece.
|
/// An object which can be used to construct a script piece by piece.
|
||||||
#[derive(PartialEq, Eq, Clone)]
|
#[derive(PartialEq, Eq, Clone)]
|
||||||
pub struct Builder(ScriptBuf, Option<opcodes::All>);
|
pub struct Builder(ScriptBuf, Option<opcodes::All>);
|
||||||
|
|
Loading…
Reference in New Issue