Skip to content

Commit bd08591

Browse files
adamnemecek9prady9
authored andcommitted
use self
1 parent 5d2ae2d commit bd08591

File tree

8 files changed

+30
-30
lines changed

8 files changed

+30
-30
lines changed

src/array.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ where
173173
/// print(&indices);
174174
/// ```
175175
#[allow(unused_mut)]
176-
pub fn new(slice: &[T], dims: Dim4) -> Array<T> {
176+
pub fn new(slice: &[T], dims: Dim4) -> Self {
177177
let aftype = T::get_af_dtype();
178178
let mut temp: i64 = 0;
179179
unsafe {
@@ -193,7 +193,7 @@ where
193193
///
194194
/// The data pointed by the slice passed to this function can possibily be offseted using an additional `offset` parameter.
195195
#[allow(unused_mut)]
196-
pub fn new_strided(slice: &[T], offset: i64, dims: Dim4, strides: Dim4) -> Array<T> {
196+
pub fn new_strided(slice: &[T], offset: i64, dims: Dim4, strides: Dim4) -> Self {
197197
let aftype = T::get_af_dtype();
198198
let mut temp: i64 = 0;
199199
unsafe {
@@ -221,7 +221,7 @@ where
221221
/// let garbageVals = Array::<f32>::new_empty(Dim4::new(&[3, 1, 1, 1]));
222222
/// ```
223223
#[allow(unused_mut)]
224-
pub fn new_empty(dims: Dim4) -> Array<T> {
224+
pub fn new_empty(dims: Dim4) -> Self {
225225
let aftype = T::get_af_dtype();
226226
unsafe {
227227
let mut temp: i64 = 0;
@@ -375,7 +375,7 @@ where
375375
/// Makes an copy of the Array
376376
///
377377
/// This does a deep copy of the data into a new Array
378-
pub fn copy(&self) -> Array<T> {
378+
pub fn copy(&self) -> Self {
379379
unsafe {
380380
let mut temp: i64 = 0;
381381
let err_val = af_copy_array(&mut temp as MutAfArray, self.handle as AfArray);
@@ -522,7 +522,7 @@ impl<T> Clone for Array<T>
522522
where
523523
T: HasAfEnum,
524524
{
525-
fn clone(&self) -> Array<T> {
525+
fn clone(&self) -> Self {
526526
unsafe {
527527
let mut temp: i64 = 0;
528528
let ret_val = af_retain_array(&mut temp as MutAfArray, self.handle as AfArray);

src/dim4.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ pub struct Dim4 {
99

1010
/// Default trait for Dim4 returns an Array of dimensions [1, 1, 1, 1]
1111
impl Default for Dim4 {
12-
fn default() -> Dim4 {
13-
Dim4 { dims: [1, 1, 1, 1] }
12+
fn default() -> Self {
13+
Self { dims: [1, 1, 1, 1] }
1414
}
1515
}
1616

@@ -64,8 +64,8 @@ impl Dim4 {
6464
/// use arrayfire::Dim4;
6565
/// let dims = Dim4::new(&[4, 4, 2, 1]);
6666
/// ```
67-
pub fn new(dims: &[u64; 4]) -> Dim4 {
68-
Dim4 { dims: dims.clone() }
67+
pub fn new(dims: &[u64; 4]) -> Self {
68+
Self { dims: dims.clone() }
6969
}
7070

7171
/// Get the number of elements represented by Dim4 object

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub struct Callback {
2424
impl Callback {
2525
/// Associated function to create a new Callback object
2626
pub fn new(callback: ErrorCallback) -> Self {
27-
Callback { cb: callback }
27+
Self { cb: callback }
2828
}
2929

3030
/// call invokes the error callback with `error_code`.

src/graphics.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ pub struct Window {
174174

175175
/// Used to create Window object from native(ArrayFire) resource handle
176176
impl From<u64> for Window {
177-
fn from(t: u64) -> Window {
178-
Window {
177+
fn from(t: u64) -> Self {
178+
Self {
179179
handle: t,
180180
row: -1,
181181
col: -1,
@@ -212,7 +212,7 @@ impl Window {
212212
///
213213
/// Window Object
214214
#[allow(unused_mut)]
215-
pub fn new(width: i32, height: i32, title: String) -> Window {
215+
pub fn new(width: i32, height: i32, title: String) -> Self {
216216
unsafe {
217217
let mut temp: u64 = 0;
218218
let cstr_ret = CString::new(title);
@@ -225,7 +225,7 @@ impl Window {
225225
cstr.as_ptr(),
226226
);
227227
HANDLE_ERROR(AfError::from(err_val));
228-
Window::from(temp)
228+
Self::from(temp)
229229
}
230230
Err(_) => {
231231
panic!("String creation failed while prepping params for window creation.")

src/index.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ where
155155
impl<'object> Indexer<'object> {
156156
#[allow(unused_mut)]
157157
/// Create a new Indexer object and set the dimension specific index objects later
158-
pub fn new() -> Indexer<'object> {
158+
pub fn new() -> Self {
159159
let mut temp: i64 = 0;
160160
unsafe {
161161
let err_val = af_create_indexers(&mut temp as MutAfIndex);
162162
HANDLE_ERROR(AfError::from(err_val));
163163
}
164-
Indexer {
164+
Self {
165165
handle: temp,
166166
count: 0,
167167
marker: PhantomData,
@@ -596,7 +596,7 @@ impl SeqInternal {
596596
where
597597
c_double: From<T>,
598598
{
599-
SeqInternal {
599+
Self {
600600
begin: From::from(s.begin()),
601601
end: From::from(s.end()),
602602
step: From::from(s.step()),

src/seq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub struct Seq<T> {
1616
/// Default `Seq` spans all the elements along a dimension
1717
impl<T: One + Zero> Default for Seq<T> {
1818
fn default() -> Self {
19-
Seq {
19+
Self {
2020
begin: One::one(),
2121
end: One::one(),
2222
step: Zero::zero(),
@@ -38,7 +38,7 @@ impl<T: fmt::Display> fmt::Display for Seq<T> {
3838
impl<T: Copy> Seq<T> {
3939
/// Create a `Seq` that goes from `begin` to `end` at a step size of `step`
4040
pub fn new(begin: T, end: T, step: T) -> Self {
41-
Seq {
41+
Self {
4242
begin: begin,
4343
end: end,
4444
step: step,

src/util.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,42 +71,42 @@ pub fn free_host<T>(ptr: *mut T) {
7171
}
7272

7373
impl From<i32> for AfError {
74-
fn from(t: i32) -> AfError {
74+
fn from(t: i32) -> Self {
7575
assert!(AfError::SUCCESS as i32 <= t && t <= AfError::ERR_UNKNOWN as i32);
7676
unsafe { mem::transmute(t) }
7777
}
7878
}
7979

8080
impl From<u32> for DType {
81-
fn from(t: u32) -> DType {
81+
fn from(t: u32) -> Self {
8282
assert!(DType::F32 as u32 <= t && t <= DType::U64 as u32);
8383
unsafe { mem::transmute(t) }
8484
}
8585
}
8686

8787
impl From<u32> for InterpType {
88-
fn from(t: u32) -> InterpType {
88+
fn from(t: u32) -> Self {
8989
assert!(InterpType::NEAREST as u32 <= t && t <= InterpType::BICUBIC_SPLINE as u32);
9090
unsafe { mem::transmute(t) }
9191
}
9292
}
9393

9494
impl From<u32> for ConvMode {
95-
fn from(t: u32) -> ConvMode {
95+
fn from(t: u32) -> Self {
9696
assert!(ConvMode::DEFAULT as u32 <= t && t <= ConvMode::EXPAND as u32);
9797
unsafe { mem::transmute(t) }
9898
}
9999
}
100100

101101
impl From<u32> for ConvDomain {
102-
fn from(t: u32) -> ConvDomain {
102+
fn from(t: u32) -> Self {
103103
assert!(ConvDomain::AUTO as u32 <= t && t <= ConvDomain::FREQUENCY as u32);
104104
unsafe { mem::transmute(t) }
105105
}
106106
}
107107

108108
impl From<u32> for MatchType {
109-
fn from(t: u32) -> MatchType {
109+
fn from(t: u32) -> Self {
110110
assert!(MatchType::SAD as u32 <= t && t <= MatchType::SHD as u32);
111111
unsafe { mem::transmute(t) }
112112
}
@@ -129,7 +129,7 @@ pub fn to_u32(t: MatProp) -> u32 {
129129
}
130130

131131
impl From<u32> for ColorMap {
132-
fn from(t: u32) -> ColorMap {
132+
fn from(t: u32) -> Self {
133133
assert!(ColorMap::DEFAULT as u32 <= t && t <= ColorMap::BLUE as u32);
134134
unsafe { mem::transmute(t) }
135135
}

src/vision/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ impl Features {
158158
///
159159
/// This object is basically a bunch of Arrays.
160160
#[allow(unused_mut)]
161-
pub fn new(n: u64) -> Features {
161+
pub fn new(n: u64) -> Self {
162162
unsafe {
163163
let mut temp: i64 = 0;
164164
let err_val = af_create_features(&mut temp as *mut c_longlong as MutFeat, n as DimT);
165165
HANDLE_ERROR(AfError::from(err_val));
166-
Features { feat: temp }
166+
Self { feat: temp }
167167
}
168168
}
169169

@@ -197,15 +197,15 @@ impl Features {
197197
}
198198

199199
impl Clone for Features {
200-
fn clone(&self) -> Features {
200+
fn clone(&self) -> Self {
201201
unsafe {
202202
let mut temp: i64 = 0;
203203
let ret_val = af_retain_features(
204204
&mut temp as *mut c_longlong as MutFeat,
205205
self.feat as *const c_longlong as Feat,
206206
);
207207
HANDLE_ERROR(AfError::from(ret_val));
208-
Features { feat: temp }
208+
Self { feat: temp }
209209
}
210210
}
211211
}

0 commit comments

Comments
 (0)