Skip to content

Commit 94e6fea

Browse files
committed
Prefix unchecked to postfix
1 parent 57485b3 commit 94e6fea

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/coordinate/mod.rs

+35-35
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ pub trait CoordinateSet: CoordinateMetadata {
189189
/// Geodesy operators.
190190
///
191191
/// 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
194194
/// [`dim()`](Self::dim()),
195195
/// which must be provided by the implementer.
196196
///
@@ -201,46 +201,46 @@ pub trait CoordinateTuple {
201201
/// Access the n'th (0-based) element of the CoordinateTuple.
202202
/// May panic if n >= DIMENSION.
203203
/// See also [`nth()`](Self::nth).
204-
fn unchecked_nth(&self, n: usize) -> f64;
204+
fn nth_unchecked(&self, n: usize) -> f64;
205205

206206
/// Replace the n'th (0-based) element of the `CoordinateTuple` with `value`.
207207
/// May panic if `n >=` [`dim()`](Self::dim()).
208208
/// 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);
210210

211211
/// Native dimension of the coordinate tuple
212212
fn dim(&self) -> usize;
213213

214214
/// Access the n'th (0-based) element of the CoordinateTuple.
215215
/// Returns NaN if `n >= DIMENSION`.
216-
/// See also [`unchecked_nth()`](Self::unchecked_nth).
216+
/// See also [`nth()`](Self::nth_unchecked).
217217
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}
219219
}
220220

221-
// Note: We use unchecked_nth and explicitly check for dimension in
221+
// Note: We use nth_unchecked and explicitly check for dimension in
222222
// y(), z() and t(), rather than leaving the check to nth(...).
223223
// This is because the checks in these cases are constant expressions, and
224224
// hence can be eliminated by the compiler in the concrete implementations.
225225

226226
/// Pragmatically named accessor for the first element of the CoordinateTuple.
227227
fn x(&self) -> f64 {
228-
self.unchecked_nth(0)
228+
self.nth_unchecked(0)
229229
}
230230

231231
/// Pragmatically named accessor for the second element of the CoordinateTuple.
232232
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}
234234
}
235235

236236
/// Pragmatically named accessor for the third element of the CoordinateTuple.
237237
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}
239239
}
240240

241241
/// Pragmatically named accessor for the fourth element of the CoordinateTuple.
242242
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}
244244
}
245245

246246
/// A tuple containing the first two components of the CoordinateTuple.
@@ -315,28 +315,28 @@ pub trait CoordinateTuple {
315315
/// Fill all elements of `self` with `value`
316316
fn fill(&mut self, value: f64) {
317317
for n in 0..self.dim() {
318-
self.unchecked_set_nth(n, value);
318+
self.set_nth_unchecked(n, value);
319319
}
320320
}
321321

322322
/// Replace the n'th (0-based) element of the `CoordinateTuple` with `value`.
323323
/// 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).
325325
fn set_nth(&mut self, n: usize, value: f64) {
326326
if n < self.dim() {
327-
self.unchecked_set_nth(n, value)
327+
self.set_nth_unchecked(n, value)
328328
} else {
329329
self.fill(f64::NAN);
330330
}
331331
}
332332

333333
/// Replace the two first elements of the `CoordinateTuple` with `x` and `y`.
334334
/// 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).
336336
fn set_xy(&mut self, x: f64, y: f64) {
337337
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);
340340
} else {
341341
self.fill(f64::NAN);
342342
}
@@ -346,9 +346,9 @@ pub trait CoordinateTuple {
346346
/// If the dimension is less than 3, fill the coordinate with `f64::NAN`.
347347
fn set_xyz(&mut self, x: f64, y: f64, z: f64) {
348348
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);
352352
} else {
353353
self.fill(f64::NAN);
354354
}
@@ -358,10 +358,10 @@ pub trait CoordinateTuple {
358358
/// If the dimension in less than 4, fill the coordinate with `f64::NAN`.
359359
fn set_xyzt(&mut self, x: f64, y: f64, z: f64, t: f64) {
360360
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);
365365
} else {
366366
self.fill(f64::NAN);
367367
}
@@ -373,7 +373,7 @@ pub trait CoordinateTuple {
373373
fn update(&mut self, value: &[f64]) {
374374
let n = value.len().min(self.dim());
375375
for i in 0..n {
376-
self.unchecked_set_nth(i, value[i])
376+
self.set_nth_unchecked(i, value[i])
377377
}
378378
}
379379

@@ -449,11 +449,11 @@ impl CoordinateTuple for Coor2D {
449449
2
450450
}
451451

452-
fn unchecked_nth(&self, n: usize) -> f64 {
452+
fn nth_unchecked(&self, n: usize) -> f64 {
453453
self.0[n]
454454
}
455455

456-
fn unchecked_set_nth(&mut self, n: usize, value: f64) {
456+
fn set_nth_unchecked(&mut self, n: usize, value: f64) {
457457
self.0[n] = value;
458458
}
459459
}
@@ -463,11 +463,11 @@ impl CoordinateTuple for Coor3D {
463463
3
464464
}
465465

466-
fn unchecked_nth(&self, n: usize) -> f64 {
466+
fn nth_unchecked(&self, n: usize) -> f64 {
467467
self.0[n]
468468
}
469469

470-
fn unchecked_set_nth(&mut self, n: usize, value: f64) {
470+
fn set_nth_unchecked(&mut self, n: usize, value: f64) {
471471
self.0[n] = value;
472472
}
473473
}
@@ -477,11 +477,11 @@ impl CoordinateTuple for Coor4D {
477477
4
478478
}
479479

480-
fn unchecked_nth(&self, n: usize) -> f64 {
480+
fn nth_unchecked(&self, n: usize) -> f64 {
481481
self.0[n]
482482
}
483483

484-
fn unchecked_set_nth(&mut self, n: usize, value: f64) {
484+
fn set_nth_unchecked(&mut self, n: usize, value: f64) {
485485
self.0[n] = value;
486486
}
487487
}
@@ -491,11 +491,11 @@ impl CoordinateTuple for Coor32 {
491491
2
492492
}
493493

494-
fn unchecked_nth(&self, n: usize) -> f64 {
494+
fn nth_unchecked(&self, n: usize) -> f64 {
495495
self.0[n] as f64
496496
}
497497

498-
fn unchecked_set_nth(&mut self, n: usize, value: f64) {
498+
fn set_nth_unchecked(&mut self, n: usize, value: f64) {
499499
self.0[n] = value as f32;
500500
}
501501
}
@@ -505,15 +505,15 @@ impl CoordinateTuple for Coor32 {
505505
impl CoordinateTuple for (f64, f64) {
506506
fn dim(&self) -> usize { 2 }
507507

508-
fn unchecked_nth(&self, n: usize) -> f64 {
508+
fn nth_unchecked(&self, n: usize) -> f64 {
509509
match n {
510510
0 => self.0,
511511
1 => self.1,
512512
_ => panic!()
513513
}
514514
}
515515

516-
fn unchecked_set_nth(&mut self, n: usize, value: f64) {
516+
fn set_nth_unchecked(&mut self, n: usize, value: f64) {
517517
match n {
518518
0 => self.0 = value,
519519
1 => self.1 = value,

0 commit comments

Comments
 (0)