Threads: a metric size without a coarse pitch suggests its fine pitches again

The thread forms (b4549d270) parse designations in thread_forms, whose refusal for a plain
M28 said "give it: M28x1" and, for M0 or M1e9, still offered a pitch. The hint the hole
command gave (the two coarsest ISO fine pitches that suit the diameter: M28x2 or M28x1.5) is
now thread_forms::no_coarse_pitch, used by both; a diameter no metric thread has is an
unknown metric thread. The test's "unknown thread" follows the forms' wording ("unknown
metric thread").

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-29 12:05:37 -04:00
1 parent f8c2fba077
commit 5cc0d5e9c4
3 files changed
+16 -11

No files matched your search

+1 -9
View File
@@ -2343,16 +2343,8 @@ fn clearance_diameter(size: &str, fit: &str) -> Option<f64> {
/// The pitches to try for a plain `M<d>` that has no ISO coarse pitch, `None` for anything else.
fn fine_only_hint(t: &str) -> Option<String> {
const PITCHES: [f64; 9] = [2.0, 1.5, 1.25, 1.0, 0.75, 0.5, 0.35, 0.25, 0.2];
let diameter = t.trim().strip_prefix(['M', 'm']).and_then(|d| d.trim().parse::<f64>().ok());
if let Some(d) = diameter.filter(|d| d.is_finite() && *d > 0.2 && *d <= 1e4) {
let first = PITCHES.iter().position(|p| *p <= 0.12 * d).unwrap_or(PITCHES.len() - 1);
let pitches: Vec<String> = PITCHES.iter().skip(first).take(2).filter(|p| **p < d).map(|p| format!("M{d}x{p}")).collect();
if !pitches.is_empty() {
return Some(format!("M{d} has no coarse ISO pitch: give one, e.g. {}", pitches.join(" or ")));
}
}
None
diameter.and_then(solidcraft_doc::thread_forms::no_coarse_pitch)
}
/// Largest nominal diameter automatic thread sizing knows (the last ISO coarse size).