Skip to content

Commit 0ec8fab

Browse files
committed
stop explicitly casting references to rawptrs
1 parent 37049d7 commit 0ec8fab

File tree

5 files changed

+18
-20
lines changed

5 files changed

+18
-20
lines changed

secp256k1-sys/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ impl<T> CPtr for [T] {
661661

662662
fn as_mut_c_ptr(&mut self) -> *mut Self::Target {
663663
if self.is_empty() {
664-
ptr::null::<Self::Target>() as *mut _
664+
ptr::null_mut::<Self::Target>()
665665
} else {
666666
self.as_mut_ptr()
667667
}

src/key.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,13 @@ impl PublicKey {
219219
/// Obtains a raw const pointer suitable for use with FFI functions
220220
#[inline]
221221
pub fn as_ptr(&self) -> *const ffi::PublicKey {
222-
&self.0 as *const _
222+
&self.0
223223
}
224224

225225
/// Obtains a raw mutable pointer suitable for use with FFI functions
226226
#[inline]
227227
pub fn as_mut_ptr(&mut self) -> *mut ffi::PublicKey {
228-
&mut self.0 as *mut _
228+
&mut self.0
229229
}
230230

231231
/// Creates a new public key from a secret key.
@@ -313,7 +313,7 @@ impl PublicKey {
313313
secp: &Secp256k1<C>
314314
) {
315315
unsafe {
316-
let res = ffi::secp256k1_ec_pubkey_negate(secp.ctx, &mut self.0 as *mut _);
316+
let res = ffi::secp256k1_ec_pubkey_negate(secp.ctx, &mut self.0);
317317
debug_assert_eq!(res, 1);
318318
}
319319
}
@@ -331,8 +331,7 @@ impl PublicKey {
331331
return Err(Error::InvalidTweak);
332332
}
333333
unsafe {
334-
if ffi::secp256k1_ec_pubkey_tweak_add(secp.ctx, &mut self.0 as *mut _,
335-
other.as_c_ptr()) == 1 {
334+
if ffi::secp256k1_ec_pubkey_tweak_add(secp.ctx, &mut self.0, other.as_c_ptr()) == 1 {
336335
Ok(())
337336
} else {
338337
Err(Error::InvalidTweak)
@@ -353,8 +352,7 @@ impl PublicKey {
353352
return Err(Error::InvalidTweak);
354353
}
355354
unsafe {
356-
if ffi::secp256k1_ec_pubkey_tweak_mul(secp.ctx, &mut self.0 as *mut _,
357-
other.as_c_ptr()) == 1 {
355+
if ffi::secp256k1_ec_pubkey_tweak_mul(secp.ctx, &mut self.0, other.as_c_ptr()) == 1 {
358356
Ok(())
359357
} else {
360358
Err(Error::InvalidTweak)

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,13 @@ impl Signature {
361361
/// Obtains a raw pointer suitable for use with FFI functions
362362
#[inline]
363363
pub fn as_ptr(&self) -> *const ffi::Signature {
364-
&self.0 as *const _
364+
&self.0
365365
}
366366

367367
/// Obtains a raw mutable pointer suitable for use with FFI functions
368368
#[inline]
369369
pub fn as_mut_ptr(&mut self) -> *mut ffi::Signature {
370-
&mut self.0 as *mut _
370+
&mut self.0
371371
}
372372

373373
#[inline]

src/recovery.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ impl RecoverableSignature {
8282
/// Obtains a raw pointer suitable for use with FFI functions
8383
#[inline]
8484
pub fn as_ptr(&self) -> *const ffi::RecoverableSignature {
85-
&self.0 as *const _
85+
&self.0
8686
}
8787

8888
/// Obtains a raw mutable pointer suitable for use with FFI functions
8989
#[inline]
9090
pub fn as_mut_ptr(&mut self) -> *mut ffi::RecoverableSignature {
91-
&mut self.0 as *mut _
91+
&mut self.0
9292
}
9393

9494
#[inline]

src/schnorrsig.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ impl KeyPair {
104104
/// Obtains a raw const pointer suitable for use with FFI functions
105105
#[inline]
106106
pub fn as_ptr(&self) -> *const ffi::KeyPair {
107-
&self.0 as *const _
107+
&self.0
108108
}
109109

110110
/// Obtains a raw mutable pointer suitable for use with FFI functions
111111
#[inline]
112112
pub fn as_mut_ptr(&mut self) -> *mut ffi::KeyPair {
113-
&mut self.0 as *mut _
113+
&mut self.0
114114
}
115115

116116
/// Creates a Schnorr KeyPair directly from a secret key slice
@@ -181,7 +181,7 @@ impl KeyPair {
181181
unsafe {
182182
let err = ffi::secp256k1_keypair_xonly_tweak_add(
183183
secp.ctx,
184-
&mut self.0 as *mut _,
184+
&mut self.0,
185185
tweak.as_c_ptr(),
186186
);
187187

@@ -198,13 +198,13 @@ impl PublicKey {
198198
/// Obtains a raw const pointer suitable for use with FFI functions
199199
#[inline]
200200
pub fn as_ptr(&self) -> *const ffi::XOnlyPublicKey {
201-
&self.0 as *const _
201+
&self.0
202202
}
203203

204204
/// Obtains a raw mutable pointer suitable for use with FFI functions
205205
#[inline]
206206
pub fn as_mut_ptr(&mut self) -> *mut ffi::XOnlyPublicKey {
207-
&mut self.0 as *mut _
207+
&mut self.0
208208
}
209209

210210
/// Creates a new Schnorr public key from a Schnorr key pair
@@ -295,8 +295,8 @@ impl PublicKey {
295295
let mut parity: ::secp256k1_sys::types::c_int = 0;
296296
err = ffi::secp256k1_xonly_pubkey_from_pubkey(
297297
secp.ctx,
298-
&mut self.0 as *mut _,
299-
&mut parity as *mut _,
298+
&mut self.0,
299+
&mut parity,
300300
&pubkey,
301301
);
302302

@@ -334,7 +334,7 @@ impl PublicKey {
334334
secp.ctx,
335335
tweaked_ser.as_c_ptr(),
336336
if tweaked_parity { 1 } else { 0 },
337-
&self.0 as *const _,
337+
&self.0,
338338
tweak.as_c_ptr(),
339339
);
340340

0 commit comments

Comments
 (0)