From 1e02c3d0b9cb11913887d73d4bb3b24e2d94504d Mon Sep 17 00:00:00 2001 From: adamnemecek Date: Thu, 28 Mar 2019 07:17:17 -0700 Subject: [PATCH] Use self keyword instead of identifiers where appropriate (#194) --- src/random/mod.rs | 8 ++++---- src/util.rs | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/random/mod.rs b/src/random/mod.rs index d2591da36..a70b285e1 100644 --- a/src/random/mod.rs +++ b/src/random/mod.rs @@ -112,8 +112,8 @@ pub struct RandomEngine { /// Used for creating RandomEngine object from native resource id impl From for RandomEngine { - fn from(t: i64) -> RandomEngine { - RandomEngine { handle: t } + fn from(t: i64) -> Self { + Self { handle: t } } } @@ -128,7 +128,7 @@ impl RandomEngine { /// # Return Values /// /// A object of type RandomEngine - pub fn new(rengine: RandomEngineType, seed: Option) -> RandomEngine { + pub fn new(rengine: RandomEngineType, seed: Option) -> Self { let mut temp: i64 = 0; unsafe { let err_val = af_create_random_engine( @@ -192,7 +192,7 @@ impl RandomEngine { /// Increment reference count of RandomEngine's native resource impl Clone for RandomEngine { - fn clone(&self) -> RandomEngine { + fn clone(&self) -> Self { unsafe { let mut temp: i64 = 0; let err_val = diff --git a/src/util.rs b/src/util.rs index f23c4f148..9a9766126 100644 --- a/src/util.rs +++ b/src/util.rs @@ -384,21 +384,21 @@ impl HasAfEnum for u64 { } impl From for SparseFormat { - fn from(t: u32) -> SparseFormat { + fn from(t: u32) -> Self { assert!(SparseFormat::DENSE as u32 <= t && t <= SparseFormat::COO as u32); unsafe { mem::transmute(t) } } } impl From for BinaryOp { - fn from(t: u32) -> BinaryOp { + fn from(t: u32) -> Self { assert!(BinaryOp::ADD as u32 <= t && t <= BinaryOp::MAX as u32); unsafe { mem::transmute(t) } } } impl From for RandomEngineType { - fn from(t: u32) -> RandomEngineType { + fn from(t: u32) -> Self { assert!( RandomEngineType::PHILOX_4X32_10 as u32 <= t && t <= RandomEngineType::MERSENNE_GP11213 as u32 @@ -598,13 +598,13 @@ implicit!(bool, u8 => u8); impl Zero for Complex64 { fn zero() -> Self { - Complex64 { re: 0.0, im: 0.0 } + Self { re: 0.0, im: 0.0 } } } impl Zero for Complex32 { fn zero() -> Self { - Complex32 { re: 0.0, im: 0.0 } + Self { re: 0.0, im: 0.0 } } }