@@ -189,8 +189,8 @@ pub trait CoordinateSet: CoordinateMetadata {
189
189
/// Geodesy operators.
190
190
///
191
191
/// All accessors have default implementations, except the 3 methods
192
- /// [`unchecked_nth ()`](Self::unchecked_nth ()),
193
- /// [`unchecked_set_nth ()`](Self::unchecked_set_nth ) and
192
+ /// [`nth_unchecked ()`](Self::nth_unchecked ()),
193
+ /// [`set_nth_unchecked ()`](Self::set_nth_unchecked ) and
194
194
/// [`dim()`](Self::dim()),
195
195
/// which must be provided by the implementer.
196
196
///
@@ -201,46 +201,46 @@ pub trait CoordinateTuple {
201
201
/// Access the n'th (0-based) element of the CoordinateTuple.
202
202
/// May panic if n >= DIMENSION.
203
203
/// See also [`nth()`](Self::nth).
204
- fn unchecked_nth ( & self , n : usize ) -> f64 ;
204
+ fn nth_unchecked ( & self , n : usize ) -> f64 ;
205
205
206
206
/// Replace the n'th (0-based) element of the `CoordinateTuple` with `value`.
207
207
/// May panic if `n >=` [`dim()`](Self::dim()).
208
208
/// See also [`set_nth()`](Self::set_nth).
209
- fn unchecked_set_nth ( & mut self , n : usize , value : f64 ) ;
209
+ fn set_nth_unchecked ( & mut self , n : usize , value : f64 ) ;
210
210
211
211
/// Native dimension of the coordinate tuple
212
212
fn dim ( & self ) -> usize ;
213
213
214
214
/// Access the n'th (0-based) element of the CoordinateTuple.
215
215
/// Returns NaN if `n >= DIMENSION`.
216
- /// See also [`unchecked_nth ()`](Self::unchecked_nth ).
216
+ /// See also [`nth ()`](Self::nth_unchecked ).
217
217
fn nth ( & self , n : usize ) -> f64 {
218
- if n < self . dim ( ) { self . unchecked_nth ( n) } else { f64:: NAN }
218
+ if n < self . dim ( ) { self . nth_unchecked ( n) } else { f64:: NAN }
219
219
}
220
220
221
- // Note: We use unchecked_nth and explicitly check for dimension in
221
+ // Note: We use nth_unchecked and explicitly check for dimension in
222
222
// y(), z() and t(), rather than leaving the check to nth(...).
223
223
// This is because the checks in these cases are constant expressions, and
224
224
// hence can be eliminated by the compiler in the concrete implementations.
225
225
226
226
/// Pragmatically named accessor for the first element of the CoordinateTuple.
227
227
fn x ( & self ) -> f64 {
228
- self . unchecked_nth ( 0 )
228
+ self . nth_unchecked ( 0 )
229
229
}
230
230
231
231
/// Pragmatically named accessor for the second element of the CoordinateTuple.
232
232
fn y ( & self ) -> f64 {
233
- if self . dim ( ) > 1 { self . unchecked_nth ( 1 ) } else { f64:: NAN }
233
+ if self . dim ( ) > 1 { self . nth_unchecked ( 1 ) } else { f64:: NAN }
234
234
}
235
235
236
236
/// Pragmatically named accessor for the third element of the CoordinateTuple.
237
237
fn z ( & self ) -> f64 {
238
- if self . dim ( ) > 2 { self . unchecked_nth ( 2 ) } else { f64:: NAN }
238
+ if self . dim ( ) > 2 { self . nth_unchecked ( 2 ) } else { f64:: NAN }
239
239
}
240
240
241
241
/// Pragmatically named accessor for the fourth element of the CoordinateTuple.
242
242
fn t ( & self ) -> f64 {
243
- if self . dim ( ) > 3 { self . unchecked_nth ( 3 ) } else { f64:: NAN }
243
+ if self . dim ( ) > 3 { self . nth_unchecked ( 3 ) } else { f64:: NAN }
244
244
}
245
245
246
246
/// A tuple containing the first two components of the CoordinateTuple.
@@ -315,28 +315,28 @@ pub trait CoordinateTuple {
315
315
/// Fill all elements of `self` with `value`
316
316
fn fill ( & mut self , value : f64 ) {
317
317
for n in 0 ..self . dim ( ) {
318
- self . unchecked_set_nth ( n, value) ;
318
+ self . set_nth_unchecked ( n, value) ;
319
319
}
320
320
}
321
321
322
322
/// Replace the n'th (0-based) element of the `CoordinateTuple` with `value`.
323
323
/// If `n >=` [`dim()`](Self::dim()) fill the coordinate with `f64::NAN`.
324
- /// See also [`unchecked_set_nth ()`](Self::unchecked_set_nth ).
324
+ /// See also [`set_nth_unchecked ()`](Self::set_nth_unchecked ).
325
325
fn set_nth ( & mut self , n : usize , value : f64 ) {
326
326
if n < self . dim ( ) {
327
- self . unchecked_set_nth ( n, value)
327
+ self . set_nth_unchecked ( n, value)
328
328
} else {
329
329
self . fill ( f64:: NAN ) ;
330
330
}
331
331
}
332
332
333
333
/// Replace the two first elements of the `CoordinateTuple` with `x` and `y`.
334
334
/// If the dimension in less than 2, fill the coordinate with `f64::NAN`.
335
- /// See also [`unchecked_set_nth ()`](Self::unchecked_set_nth ).
335
+ /// See also [`set_nth_unchecked ()`](Self::set_nth_unchecked ).
336
336
fn set_xy ( & mut self , x : f64 , y : f64 ) {
337
337
if self . dim ( ) > 1 {
338
- self . unchecked_set_nth ( 0 , x) ;
339
- self . unchecked_set_nth ( 1 , y) ;
338
+ self . set_nth_unchecked ( 0 , x) ;
339
+ self . set_nth_unchecked ( 1 , y) ;
340
340
} else {
341
341
self . fill ( f64:: NAN ) ;
342
342
}
@@ -346,9 +346,9 @@ pub trait CoordinateTuple {
346
346
/// If the dimension is less than 3, fill the coordinate with `f64::NAN`.
347
347
fn set_xyz ( & mut self , x : f64 , y : f64 , z : f64 ) {
348
348
if self . dim ( ) > 2 {
349
- self . unchecked_set_nth ( 0 , x) ;
350
- self . unchecked_set_nth ( 1 , y) ;
351
- self . unchecked_set_nth ( 2 , z) ;
349
+ self . set_nth_unchecked ( 0 , x) ;
350
+ self . set_nth_unchecked ( 1 , y) ;
351
+ self . set_nth_unchecked ( 2 , z) ;
352
352
} else {
353
353
self . fill ( f64:: NAN ) ;
354
354
}
@@ -358,10 +358,10 @@ pub trait CoordinateTuple {
358
358
/// If the dimension in less than 4, fill the coordinate with `f64::NAN`.
359
359
fn set_xyzt ( & mut self , x : f64 , y : f64 , z : f64 , t : f64 ) {
360
360
if self . dim ( ) > 3 {
361
- self . unchecked_set_nth ( 0 , x) ;
362
- self . unchecked_set_nth ( 1 , y) ;
363
- self . unchecked_set_nth ( 2 , z) ;
364
- self . unchecked_set_nth ( 3 , t) ;
361
+ self . set_nth_unchecked ( 0 , x) ;
362
+ self . set_nth_unchecked ( 1 , y) ;
363
+ self . set_nth_unchecked ( 2 , z) ;
364
+ self . set_nth_unchecked ( 3 , t) ;
365
365
} else {
366
366
self . fill ( f64:: NAN ) ;
367
367
}
@@ -373,7 +373,7 @@ pub trait CoordinateTuple {
373
373
fn update ( & mut self , value : & [ f64 ] ) {
374
374
let n = value. len ( ) . min ( self . dim ( ) ) ;
375
375
for i in 0 ..n {
376
- self . unchecked_set_nth ( i, value[ i] )
376
+ self . set_nth_unchecked ( i, value[ i] )
377
377
}
378
378
}
379
379
@@ -449,11 +449,11 @@ impl CoordinateTuple for Coor2D {
449
449
2
450
450
}
451
451
452
- fn unchecked_nth ( & self , n : usize ) -> f64 {
452
+ fn nth_unchecked ( & self , n : usize ) -> f64 {
453
453
self . 0 [ n]
454
454
}
455
455
456
- fn unchecked_set_nth ( & mut self , n : usize , value : f64 ) {
456
+ fn set_nth_unchecked ( & mut self , n : usize , value : f64 ) {
457
457
self . 0 [ n] = value;
458
458
}
459
459
}
@@ -463,11 +463,11 @@ impl CoordinateTuple for Coor3D {
463
463
3
464
464
}
465
465
466
- fn unchecked_nth ( & self , n : usize ) -> f64 {
466
+ fn nth_unchecked ( & self , n : usize ) -> f64 {
467
467
self . 0 [ n]
468
468
}
469
469
470
- fn unchecked_set_nth ( & mut self , n : usize , value : f64 ) {
470
+ fn set_nth_unchecked ( & mut self , n : usize , value : f64 ) {
471
471
self . 0 [ n] = value;
472
472
}
473
473
}
@@ -477,11 +477,11 @@ impl CoordinateTuple for Coor4D {
477
477
4
478
478
}
479
479
480
- fn unchecked_nth ( & self , n : usize ) -> f64 {
480
+ fn nth_unchecked ( & self , n : usize ) -> f64 {
481
481
self . 0 [ n]
482
482
}
483
483
484
- fn unchecked_set_nth ( & mut self , n : usize , value : f64 ) {
484
+ fn set_nth_unchecked ( & mut self , n : usize , value : f64 ) {
485
485
self . 0 [ n] = value;
486
486
}
487
487
}
@@ -491,11 +491,11 @@ impl CoordinateTuple for Coor32 {
491
491
2
492
492
}
493
493
494
- fn unchecked_nth ( & self , n : usize ) -> f64 {
494
+ fn nth_unchecked ( & self , n : usize ) -> f64 {
495
495
self . 0 [ n] as f64
496
496
}
497
497
498
- fn unchecked_set_nth ( & mut self , n : usize , value : f64 ) {
498
+ fn set_nth_unchecked ( & mut self , n : usize , value : f64 ) {
499
499
self . 0 [ n] = value as f32 ;
500
500
}
501
501
}
@@ -505,15 +505,15 @@ impl CoordinateTuple for Coor32 {
505
505
impl CoordinateTuple for ( f64 , f64 ) {
506
506
fn dim ( & self ) -> usize { 2 }
507
507
508
- fn unchecked_nth ( & self , n : usize ) -> f64 {
508
+ fn nth_unchecked ( & self , n : usize ) -> f64 {
509
509
match n {
510
510
0 => self . 0 ,
511
511
1 => self . 1 ,
512
512
_ => panic ! ( )
513
513
}
514
514
}
515
515
516
- fn unchecked_set_nth ( & mut self , n : usize , value : f64 ) {
516
+ fn set_nth_unchecked ( & mut self , n : usize , value : f64 ) {
517
517
match n {
518
518
0 => self . 0 = value,
519
519
1 => self . 1 = value,
0 commit comments