Skip to content

Commit 979f393

Browse files
committed
LrmScale have an id
1 parent bef6538 commit 979f393

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/curves.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use thiserror::Error;
1313
/// It provides basic primitives to locate/project points on it
1414
/// A curve can be part of a larger curve (e.g. for optimisation purpurses and have better bounding boxes)
1515
/// The curve can be implemented
16-
trait Curve {
16+
pub trait Curve {
1717
/// Project the point to the closest position on the curve
1818
/// Will fail if the curve is invalid (e.g. no points on it)
1919
/// or if the point is to far away

src/lrm_scale.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl ScaleBuilder {
130130
/// Requires at least one named anchor
131131
/// Will fail if none is present and if the anchors names are duplicated
132132
/// This will consume the builder that can not be used after
133-
pub fn build(self) -> Result<LrmScale, LrmScaleError> {
133+
pub fn build(self, id: &str) -> Result<LrmScale, LrmScaleError> {
134134
let mut names = std::collections::HashSet::new();
135135
for anchor in self.anchors.iter() {
136136
if let Some(name) = &anchor.id {
@@ -276,7 +276,7 @@ mod tests {
276276
fn scale() -> LrmScale {
277277
ScaleBuilder::new(Anchor::new("a", 0., 0.))
278278
.add_named("b", 10., 100.)
279-
.build()
279+
.build("id")
280280
.unwrap()
281281
}
282282

@@ -289,13 +289,13 @@ mod tests {
289289

290290
// Missing named anchor
291291
let b = ScaleBuilder::new(Anchor::new_unnamed(0., 0.));
292-
let scale = b.build();
292+
let scale = b.build("id");
293293
assert_eq!(scale, Err(LrmScaleError::NoEnoughNamedAnchor));
294294

295295
// Duplicated name
296296
let scale = ScaleBuilder::new(Anchor::new("a", 0., 0.))
297297
.add_named("a", 100., 100.)
298-
.build();
298+
.build("id");
299299
assert_eq!(
300300
scale,
301301
Err(LrmScaleError::DuplicatedAnchorName("a".to_string()))
@@ -327,7 +327,7 @@ mod tests {
327327
fn nearest_named() {
328328
let scale = ScaleBuilder::new(Anchor::new("a", 0., 2.))
329329
.add_named("b", 10., 1.)
330-
.build()
330+
.build("id")
331331
.unwrap();
332332

333333
assert_eq!(scale.nearest_named(2.1).unwrap().id, "a");
@@ -340,7 +340,7 @@ mod tests {
340340
fn locate_anchor() {
341341
let scale = ScaleBuilder::new(Anchor::new("a", 0., 0.))
342342
.add_named("b", 10., 100.)
343-
.build()
343+
.build("id")
344344
.unwrap();
345345

346346
let measure = scale.locate_anchor(40.).unwrap();
@@ -363,7 +363,7 @@ mod tests {
363363
.add_named("a", 1., 100.)
364364
.add_named("b", 1., 100.)
365365
.add_unnamed(1., 100.)
366-
.build()
366+
.build("id")
367367
.unwrap();
368368

369369
// Unamed----position----Named

0 commit comments

Comments
 (0)