Merge pull request #57 from rust-bitcoin/2018-08-no-index

remove `ops::Index` impls for `Signature`
This commit is contained in:
Tim Ruffing 2018-12-03 14:27:08 +01:00 committed by GitHub
commit b470f70e90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 50 deletions

View File

@ -1,3 +1,7 @@
# (Unreleased)
* Remove `ops::Index` implementations for `Signature`
# 0.11.4 - 2018-11-04
* Add `FromStr` and `Display` for `Signature` and both key types

View File

@ -51,19 +51,6 @@ impl str::FromStr for SecretKey {
}
}
/// The number 1 encoded as a secret key
/// Deprecated; `static` is not what I want; use `ONE_KEY` instead
pub static ONE: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 1]);
/// The number 0 encoded as a secret key
pub const ZERO_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0]);
/// The number 1 encoded as a secret key
pub const ONE_KEY: SecretKey = SecretKey([0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,

View File

@ -142,7 +142,7 @@
pub extern crate libc;
use libc::size_t;
use std::{error, fmt, ops, ptr, str};
use std::{error, fmt, ptr, str};
#[cfg(any(test, feature = "rand"))] use rand::Rng;
#[macro_use]
@ -450,42 +450,6 @@ impl From<ffi::RecoverableSignature> for RecoverableSignature {
}
}
impl ops::Index<usize> for Signature {
type Output = u8;
#[inline]
fn index(&self, index: usize) -> &u8 {
&self.0[index]
}
}
impl ops::Index<ops::Range<usize>> for Signature {
type Output = [u8];
#[inline]
fn index(&self, index: ops::Range<usize>) -> &[u8] {
&self.0[index]
}
}
impl ops::Index<ops::RangeFrom<usize>> for Signature {
type Output = [u8];
#[inline]
fn index(&self, index: ops::RangeFrom<usize>) -> &[u8] {
&self.0[index.start..]
}
}
impl ops::Index<ops::RangeFull> for Signature {
type Output = [u8];
#[inline]
fn index(&self, _: ops::RangeFull) -> &[u8] {
&self.0[..]
}
}
#[cfg(feature = "serde")]
impl ::serde::Serialize for Signature {
fn serialize<S: ::serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {