diff --git a/README.md b/README.md index 381a110..9b8da5e 100644 --- a/README.md +++ b/README.md @@ -12,4 +12,10 @@ The schema is described in [schema/lrs.fbs](schema/lrs.fbs). The library is writ If your contribution changes the schema, you will need to generate the file with flatc. The version must be the release 23.5.26. Do not use a version built from master. -`flatc -o src --rust schema/lrs.fbs` \ No newline at end of file +`flatc -o src --rust schema/lrs.fbs` + +## Norms + +### Comment convention + +See [How to write documentation in Rust](https://doc.rust-lang.org/rustdoc/how-to-write-documentation.html) to keep the code clean and clear (also [this](https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text) for other examples). \ No newline at end of file diff --git a/src/lrm_scale.rs b/src/lrm_scale.rs index 189460b..089eb3b 100644 --- a/src/lrm_scale.rs +++ b/src/lrm_scale.rs @@ -78,7 +78,7 @@ struct NamedAnchor { curve_position: CurvePosition, } -/// A helper to build a scale by adding consecutives anchors with relative distances +/// A helper to build a scale by adding consecutive anchors with relative distances /// When having all the anchors and their distances in both scale and real position, /// it is simpler to directly build the LrmScale from an Vec /// Using the builder will however ensure that the scale is valid @@ -87,14 +87,14 @@ pub struct ScaleBuilder { } impl ScaleBuilder { - /// Create a new scale with an initial anchor + /// Creates a new scale with an initial anchor pub fn new(anchor: Anchor) -> Self { Self { anchors: vec![anchor], } } - /// Builds a named anchor and adds it to the scale builder + /// Builds a named anchor and add it to the scale builder /// Distances are relative to previous anchor pub fn add_named(self, id: &str, scale_dist: ScalePosition, curve_dist: CurvePosition) -> Self { self.add(Some(id.to_owned()), scale_dist, curve_dist) @@ -164,7 +164,7 @@ pub struct LrmScaleMeasure { } impl LrmScaleMeasure { - /// Build a new LrmMeasure from an anchor name and the offset on the scale + /// Builds a new LrmMeasure from an anchor name and the offset on the scale pub fn new(anchor_name: &str, scale_offset: ScalePosition) -> Self { Self { anchor_name: anchor_name.to_owned(), @@ -173,7 +173,7 @@ impl LrmScaleMeasure { } } -/// Represents an a LRM Scale and allows to map [Measure] to a position along a curve +/// Represents an LRM Scale and allows to map [Measure] to a position along a curve #[derive(PartialEq, Debug)] pub struct LrmScale { /// Unique identifier @@ -183,7 +183,7 @@ pub struct LrmScale { } impl LrmScale { - /// Locates a point along a curve given an anchor and a offset + /// Locates a point along a curve given an anchor and an offset /// The offset might be negative pub fn locate_point(&self, measure: &LrmScaleMeasure) -> Result { let named_anchor = self @@ -207,7 +207,7 @@ impl LrmScale { &self, curve_position: CurvePosition, ) -> Result { - // First we find the nearest named anchor to the curve + // First, we find the nearest named anchor to the curve let named_anchor = self .nearest_named(curve_position) .ok_or(LrmScaleError::NoAnchorFound)?; @@ -247,7 +247,7 @@ impl LrmScale { .or_else(|| self.iter_named().next()) } - // Find the closest anchor before the anchor having the name `name` + // Finds the closest anchor before the anchor having the name `name` fn previous_anchor(&self, name: &str) -> Option<&Anchor> { self.anchors .iter() @@ -256,7 +256,7 @@ impl LrmScale { .nth(1) } - // Find the closest anchor after the anchor having the name `name` + // Finds the closest anchor after the anchor having the name `name` fn next_anchor(&self, name: &str) -> Option<&Anchor> { self.anchors .iter()