Skip to content

Commit ef4f707

Browse files
committed
doc(core): complete CMap3 documentation
I forgot there was an `#[allow()]` in there
1 parent 042da48 commit ef4f707

4 files changed

Lines changed: 54 additions & 5 deletions

File tree

honeycomb-core/src/cmap/dim3/basic_ops.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ use crate::stm::{StmClosureResult, StmError, Transaction, atomically};
2222
// not applied to orbit currently bc they are lazily onsumed, and therefore require dedicated
2323
// instances to be robust
2424
thread_local! {
25-
static AUXILIARIES: RefCell<(VecDeque<DartIdType>, HashSet<DartIdType>)> = RefCell::new((VecDeque::with_capacity(10), HashSet::with_capacity(10)));
25+
static AUXILIARIES: RefCell<(VecDeque<DartIdType>, HashSet<DartIdType>)> = RefCell::new(
26+
(
27+
VecDeque::with_capacity(10),
28+
HashSet::with_capacity(10),
29+
)
30+
);
2631
}
2732

2833
/// **Beta-related methods**
@@ -138,6 +143,12 @@ impl<T: CoordsFloat> CMap3<T> {
138143
/// # Return
139144
///
140145
/// Return a boolean indicating if the dart is 0-free, 1-free **and** 2-free.
146+
///
147+
/// # Errors
148+
///
149+
/// This method is meant to be called in a context where the returned `Result` is used to
150+
/// validate the transaction passed as argument. Errors should not be processed manually,
151+
/// only processed via the `?` operator.
141152
#[must_use = "unused return value"]
142153
pub fn is_free_tx(&self, t: &mut Transaction, dart_id: DartIdType) -> StmClosureResult<bool> {
143154
Ok(self.beta_tx::<0>(t, dart_id)? == NULL_DART_ID
@@ -417,6 +428,7 @@ impl<T: CoordsFloat> CMap3<T> {
417428
}
418429

419430
/// Return an iterator over IDs of all the map's vertices.
431+
#[must_use = "iterators are lazy and do nothing unless consumed"]
420432
pub fn par_iter_vertices(&self) -> impl ParallelIterator<Item = VertexIdType> + '_ {
421433
(1..self.n_darts() as DartIdType)
422434
.into_par_iter()
@@ -434,6 +446,7 @@ impl<T: CoordsFloat> CMap3<T> {
434446
}
435447

436448
/// Return an iterator over IDs of all the map's edges.
449+
#[must_use = "iterators are lazy and do nothing unless consumed"]
437450
pub fn par_iter_edges(&self) -> impl ParallelIterator<Item = EdgeIdType> + '_ {
438451
(1..self.n_darts() as DartIdType)
439452
.into_par_iter()
@@ -451,6 +464,7 @@ impl<T: CoordsFloat> CMap3<T> {
451464
}
452465

453466
/// Return an iterator over IDs of all the map's faces.
467+
#[must_use = "iterators are lazy and do nothing unless consumed"]
454468
pub fn par_iter_faces(&self) -> impl ParallelIterator<Item = FaceIdType> + '_ {
455469
(1..self.n_darts() as DartIdType)
456470
.into_par_iter()
@@ -468,6 +482,7 @@ impl<T: CoordsFloat> CMap3<T> {
468482
}
469483

470484
/// Return an iterator over IDs of all the map's volumes.
485+
#[must_use = "iterators are lazy and do nothing unless consumed"]
471486
pub fn par_iter_volumes(&self) -> impl ParallelIterator<Item = VolumeIdType> + '_ {
472487
(1..self.n_darts() as DartIdType)
473488
.into_par_iter()

honeycomb-core/src/cmap/dim3/links/mod.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ impl<T: CoordsFloat> CMap3<T> {
3232
/// `?` operator. The policy in case of failure can be defined when creating the transaction,
3333
/// using `Transaction::with_control`.
3434
///
35+
/// It may return an error if the transaction fails or if the link fails; See [`LinkError`] for
36+
/// more detail about the latter.
37+
///
3538
/// # Panics
3639
///
3740
/// The method may panic if:
@@ -104,6 +107,17 @@ impl<T: CoordsFloat> CMap3<T> {
104107
///
105108
/// This variant is equivalent to [`link`][Self::link], but internally uses a transaction that
106109
/// will be retried until validated.
110+
///
111+
/// # Errors
112+
///
113+
/// It may return an error if the transaction fails or if the link fails; See [`LinkError`] for
114+
/// more detail about the latter.
115+
///
116+
/// # Panics
117+
///
118+
/// The method may panic if:
119+
/// - `I >= 4` or `I == 0`,
120+
/// - `lhs_dart_id` is already `I`-free.
107121
pub fn force_link<const I: u8>(
108122
&self,
109123
lhs_dart_id: DartIdType,
@@ -124,6 +138,17 @@ impl<T: CoordsFloat> CMap3<T> {
124138
///
125139
/// This variant is equivalent to [`unlink`][Self::unlink], but internally uses a transaction
126140
/// that will be retried until validated.
141+
///
142+
/// # Errors
143+
///
144+
/// It may return an error if the transaction fails or if the link fails; See [`LinkError`] for
145+
/// more detail about the latter.
146+
///
147+
/// # Panics
148+
///
149+
/// The method may panic if:
150+
/// - `I >= 4` or `I == 0`,
151+
/// - `lhs_dart_id` is already `I`-free.
127152
pub fn force_unlink<const I: u8>(&self, lhs_dart_id: DartIdType) -> Result<(), LinkError> {
128153
// these assertions + match on a const are optimized away
129154
assert!(I < 4);

honeycomb-core/src/cmap/dim3/serialize.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ impl<T: CoordsFloat> CMap3<T> {
1010
/// Serialize the map under a custom format.
1111
///
1212
/// The format specification is described in the [user guide]().
13+
///
14+
/// # Panics
15+
///
16+
/// This method may panic if there was an error trying to open / write to the file.
1317
pub fn serialize(&self, mut writer: impl std::fmt::Write) {
1418
let n_darts = self.n_darts();
1519

@@ -95,9 +99,15 @@ impl<T: CoordsFloat> CMap3<T> {
9599
writeln!(
96100
writer,
97101
"{v} {} {} {}",
98-
val.0.to_f64().unwrap(),
99-
val.1.to_f64().unwrap(),
100-
val.2.to_f64().unwrap(),
102+
val.0
103+
.to_f64()
104+
.expect("E: unreachable, unless experimenting with f128"),
105+
val.1
106+
.to_f64()
107+
.expect("E: unreachable, unless experimenting with f128"),
108+
val.2
109+
.to_f64()
110+
.expect("E: unreachable, unless experimenting with f128"),
101111
)
102112
.expect("E: couldn't write to file");
103113
}

honeycomb-core/src/cmap/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
mod builder;
44
mod components;
55
mod dim2;
6-
#[allow(missing_docs, clippy::missing_errors_doc, clippy::missing_panics_doc)] // FIXME:write docs
76
mod dim3;
87
mod error;
98

0 commit comments

Comments
 (0)