7
7
// except according to those terms.
8
8
9
9
/// Return `s` without the `0x` at the beginning of it, if any.
10
+ #[ deprecated(
11
+ since = "0.2.5" ,
12
+ note = "out of scope for fixed-hash"
13
+ ) ]
10
14
pub fn clean_0x ( s : & str ) -> & str {
11
15
if s. starts_with ( "0x" ) {
12
16
& s[ 2 ..]
@@ -40,6 +44,10 @@ macro_rules! construct_hash {
40
44
}
41
45
}
42
46
47
+ #[ deprecated(
48
+ since = "0.2.5" ,
49
+ note = "use `as_ref` instead"
50
+ ) ]
43
51
impl :: core:: ops:: Deref for $from {
44
52
type Target = [ u8 ] ;
45
53
@@ -70,6 +78,10 @@ macro_rules! construct_hash {
70
78
}
71
79
}
72
80
81
+ #[ deprecated(
82
+ since = "0.2.5" ,
83
+ note = "use `as_mut` instead"
84
+ ) ]
73
85
impl :: core:: ops:: DerefMut for $from {
74
86
#[ inline]
75
87
fn deref_mut( & mut self ) -> & mut [ u8 ] {
@@ -79,6 +91,10 @@ macro_rules! construct_hash {
79
91
80
92
impl $from {
81
93
/// Create a new, zero-initialised, instance.
94
+ #[ deprecated(
95
+ since = "0.2.5" ,
96
+ note = "use `fixed_hash`::zero constructor instead"
97
+ ) ]
82
98
pub fn new( ) -> $from {
83
99
$from( [ 0 ; $size] )
84
100
}
@@ -89,6 +105,10 @@ macro_rules! construct_hash {
89
105
}
90
106
91
107
/// Get the size of this object in bytes.
108
+ #[ deprecated(
109
+ since = "0.2.5" ,
110
+ note = "will be renamed to `len_bytes` to avoid confusion"
111
+ ) ]
92
112
pub fn len( ) -> usize {
93
113
$size
94
114
}
@@ -104,26 +124,42 @@ macro_rules! construct_hash {
104
124
105
125
#[ inline]
106
126
/// Assign self to be of the same value as a slice of bytes of length `len()`.
127
+ #[ deprecated(
128
+ since = "0.2.5" ,
129
+ note = "unconventional API, replaced by `assign_from_slice` in version 0.3"
130
+ ) ]
107
131
pub fn clone_from_slice( & mut self , src: & [ u8 ] ) -> usize {
108
132
let min = :: core:: cmp:: min( $size, src. len( ) ) ;
109
133
self . 0 [ ..min] . copy_from_slice( & src[ ..min] ) ;
110
134
min
111
135
}
112
136
113
137
/// Convert a slice of bytes of length `len()` to an instance of this type.
138
+ #[ deprecated(
139
+ since = "0.2.5" ,
140
+ note = "unconventional API, replaced by `new_from_slice` in version 0.3"
141
+ ) ]
114
142
pub fn from_slice( src: & [ u8 ] ) -> Self {
115
143
let mut r = Self :: new( ) ;
116
144
r. clone_from_slice( src) ;
117
145
r
118
146
}
119
147
120
148
/// Copy the data of this object into some mutable slice of length `len()`.
149
+ #[ deprecated(
150
+ since = "0.2.5" ,
151
+ note = "use `std::slice` API instead"
152
+ ) ]
121
153
pub fn copy_to( & self , dest: & mut [ u8 ] ) {
122
154
let min = :: core:: cmp:: min( $size, dest. len( ) ) ;
123
155
dest[ ..min] . copy_from_slice( & self . 0 [ ..min] ) ;
124
156
}
125
157
126
158
/// Returns `true` if all bits set in `b` are also set in `self`.
159
+ #[ deprecated(
160
+ since = "0.2.5" ,
161
+ note = "will be renamed to `covers` in version 0.3"
162
+ ) ]
127
163
pub fn contains<' a>( & ' a self , b: & ' a Self ) -> bool {
128
164
& ( b & self ) == b
129
165
}
@@ -134,6 +170,10 @@ macro_rules! construct_hash {
134
170
}
135
171
136
172
/// Returns the lowest 8 bytes interpreted as a BigEndian integer.
173
+ #[ deprecated(
174
+ since = "0.2.5" ,
175
+ note = "will be renamed to `low_u64_be` in version 0.3"
176
+ ) ]
137
177
pub fn low_u64( & self ) -> u64 {
138
178
let mut ret = 0u64 ;
139
179
for i in 0 ..:: core:: cmp:: min( $size, 8 ) {
@@ -178,6 +218,7 @@ macro_rules! construct_hash {
178
218
}
179
219
180
220
impl Copy for $from { }
221
+
181
222
#[ cfg_attr( feature="dev" , allow( expl_impl_clone_on_copy) ) ]
182
223
impl Clone for $from {
183
224
fn clone( & self ) -> $from {
@@ -309,6 +350,10 @@ macro_rules! construct_hash {
309
350
fn default ( ) -> Self { $from:: new( ) }
310
351
}
311
352
353
+ #[ deprecated(
354
+ since = "0.2.5" ,
355
+ note = "will be removed because not big-/little-endian aware"
356
+ ) ]
312
357
impl From <u64 > for $from {
313
358
fn from( mut value: u64 ) -> $from {
314
359
let mut ret = $from:: new( ) ;
@@ -322,6 +367,10 @@ macro_rules! construct_hash {
322
367
}
323
368
}
324
369
370
+ #[ deprecated(
371
+ since = "0.2.5" ,
372
+ note = "misses proper error handling; will be replaced by `new_from_slice` in version 0.3"
373
+ ) ]
325
374
impl <' a> From <& ' a [ u8 ] > for $from {
326
375
fn from( s: & ' a [ u8 ] ) -> $from {
327
376
$from:: from_slice( s)
0 commit comments