Skip to content

Commit

Permalink
Merge pull request rust-bitcoin#182 from rodoufu/code_imp
Browse files Browse the repository at this point in the history
Updating libraries and small code improvements
  • Loading branch information
apoelstra committed Nov 22, 2019
2 parents 30ea7f8 + 97f74c2 commit 47b2555
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]

name = "secp256k1"
version = "0.16.0"
version = "0.16.1"
authors = [ "Dawid Ciężarkiewicz <dpc@ucore.info>",
"Andrew Poelstra <apoelstra@wpsoftware.net>" ]
license = "CC0-1.0"
Expand Down Expand Up @@ -65,4 +65,4 @@ name = "sign_verify"

[[example]]
name = "generate_keys"
required-features = ["rand"]
required-features = ["rand"]
8 changes: 4 additions & 4 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,13 +619,13 @@ mod test {
fn next_u64(&mut self) -> u64 {
self.next_u32() as u64
}
fn try_fill_bytes(&mut self, _dest: &mut [u8]) -> Result<(), Error> {
Err(Error::new(ErrorKind::Unavailable, "not implemented"))
}

fn fill_bytes(&mut self, dest: &mut [u8]) {
impls::fill_bytes_via_next(self, dest);
}

fn try_fill_bytes(&mut self, _dest: &mut [u8]) -> Result<(), Error> {
Err(Error::new(ErrorKind::Unavailable, "not implemented"))
}
}

let s = Secp256k1::new();
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ impl SerializedSignature {
pub fn from_signature(sig: &Signature) -> SerializedSignature {
sig.serialize_der()
}

/// Check if the space is zero.
pub fn is_empty(&self) -> bool { self.len() == 0 }
}

impl Signature {
Expand Down Expand Up @@ -548,7 +551,7 @@ impl Default for SerializedSignature {

impl PartialEq for SerializedSignature {
fn eq(&self, other: &SerializedSignature) -> bool {
&self.data[..self.len] == &other.data[..other.len]
self.data[..self.len] == other.data[..other.len]
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ macro_rules! impl_pretty_debug {
($thing:ident) => {
impl ::core::fmt::Debug for $thing {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
try!(write!(f, "{}(", stringify!($thing)));
write!(f, "{}(", stringify!($thing))?;
for i in self[..].iter().cloned() {
try!(write!(f, "{:02x}", i));
write!(f, "{:02x}", i)?;
}
write!(f, ")")
}
Expand All @@ -162,7 +162,7 @@ macro_rules! impl_raw_debug {
impl ::core::fmt::Debug for $thing {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
for i in self[..].iter().cloned() {
try!(write!(f, "{:02x}", i));
write!(f, "{:02x}", i)?;
}
Ok(())
}
Expand Down

0 comments on commit 47b2555

Please sign in to comment.