Skip to content

Commit

Permalink
Use self keyword instead of identifiers where appropriate (#194)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamnemecek authored and 9prady9 committed Mar 28, 2019
1 parent bd08591 commit 1e02c3d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/random/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ pub struct RandomEngine {

/// Used for creating RandomEngine object from native resource id
impl From<i64> for RandomEngine {
fn from(t: i64) -> RandomEngine {
RandomEngine { handle: t }
fn from(t: i64) -> Self {
Self { handle: t }
}
}

Expand All @@ -128,7 +128,7 @@ impl RandomEngine {
/// # Return Values
///
/// A object of type RandomEngine
pub fn new(rengine: RandomEngineType, seed: Option<u64>) -> RandomEngine {
pub fn new(rengine: RandomEngineType, seed: Option<u64>) -> Self {
let mut temp: i64 = 0;
unsafe {
let err_val = af_create_random_engine(
Expand Down Expand Up @@ -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 =
Expand Down
10 changes: 5 additions & 5 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,21 +384,21 @@ impl HasAfEnum for u64 {
}

impl From<u32> 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<u32> 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<u32> 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
Expand Down Expand Up @@ -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 }
}
}

Expand Down

0 comments on commit 1e02c3d

Please sign in to comment.