docs: Add some comments warning about race conditions, rename some identifiers

This commit is contained in:
Mikolaj Wielgus 2025-08-16 23:23:02 +02:00
parent 3738bacf6f
commit 7bb1a1efbc
4 changed files with 8 additions and 6 deletions

View File

@ -177,6 +177,8 @@ impl<
}
pub fn remove_dot(&mut self, dot: DI) {
// One of the possible causes: you have failed to delete navcord's final
// termseg.
debug_assert!(self.geometry.joined_segs(dot).next().is_none());
debug_assert!(self.geometry.joined_bends(dot).next().is_none());

View File

@ -70,7 +70,7 @@ fn bitangent_point_pairs(
circle1: Circle,
circle2: Circle,
) -> Result<Vec<(Point, Point)>, NoBitangents> {
let bitangents: Vec<(Point, Point)> = _bitangents(circle1, circle2)
let point_pairs: Vec<(Point, Point)> = _bitangents(circle1, circle2)
.into_iter()
.map(|tg| {
(
@ -80,11 +80,10 @@ fn bitangent_point_pairs(
})
.collect();
if bitangents.is_empty() {
if point_pairs.is_empty() {
return Err(NoBitangents(circle1, circle2));
}
Ok(bitangents)
Ok(point_pairs)
}
pub fn bitangents(

View File

@ -83,7 +83,7 @@ impl<R: AccessRules> Draw for Layout<R> {
into: FixedDotIndex,
width: f64,
) -> Result<BandTermsegIndex, DrawException> {
let tangent = self
let bitangent = self
.drawing()
.guide_for_head_into_dot(&head, into, width)
.map_err(Into::<DrawException>::into)?;
@ -96,7 +96,7 @@ impl<R: AccessRules> Draw for Layout<R> {
self.extend_head(
recorder,
head,
tangent.start_point(),
bitangent.start_point(),
|this, recorder| match head.face() {
DotIndex::Fixed(dot) => this
.add_lone_loose_seg(

View File

@ -94,6 +94,7 @@ impl<R: AccessRules> Navcorder for Layout<R> {
let length = navcord.path.len();
self.undo_path(navcord, length - prefix_length);
// XXX: If this fails now, there may be a race condition.
self.path(navmesh, navcord, &path[prefix_length..])
}