{"record":{"id":"8924bba2697b9774","repo":"bevyengine/bevy","slug":"cannot-extract-spaced-points-from-an-unbounded-int","errorCode":null,"errorMessage":"Cannot extract spaced points from an unbounded interval","messagePattern":"Cannot extract spaced points from an unbounded interval","errorType":"exception","errorClass":"SpacedPointsError","httpStatus":null,"severity":"error","filePath":"crates/bevy_math/src/curve/interval.rs","lineNumber":42,"sourceCode":"    reflect(Debug, PartialEq, Clone)\n)]\n#[cfg_attr(\n    all(feature = \"serialize\", feature = \"bevy_reflect\"),\n    reflect(Serialize, Deserialize)\n)]\npub struct Interval {\n    start: f32,\n    end: f32,\n}\n\n/// An error that indicates that an operation would have returned an invalid [`Interval`].\n#[derive(Debug, Error)]\n#[error(\"The resulting interval would be invalid (empty or with a NaN endpoint)\")]\npub struct InvalidIntervalError;\n\n/// An error indicating that spaced points could not be extracted from an unbounded interval.\n#[derive(Debug, Error)]\n#[error(\"Cannot extract spaced points from an unbounded interval\")]\npub struct SpacedPointsError;\n\n/// An error indicating that a linear map between intervals could not be constructed because of\n/// unboundedness.\n#[derive(Debug, Error)]\n#[error(\"Could not construct linear function to map between intervals\")]\npub(super) enum LinearMapError {\n    /// The source interval being mapped out of was unbounded.\n    #[error(\"The source interval is unbounded\")]\n    SourceUnbounded,\n\n    /// The target interval being mapped into was unbounded.\n    #[error(\"The target interval is unbounded\")]\n    TargetUnbounded,\n}\n\nimpl Interval {\n    /// Create a new [`Interval`] with the specified `start` and `end`. The interval can be unbounded","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_math/src/curve/interval.rs#L24-L60","documentation":"SpacedPointsError is returned by Interval::spaced_points when the interval is unbounded — start = -INF or end = +INF (e.g. Interval::EVERYTHING). Spaced points are evenly distributed positions across the interval at a fixed spacing or count; that is undefined over an infinite span, so the method refuses.","triggerScenarios":"interval.spaced_points(spacing) or spaced_points_inclusive on Interval::EVERYTHING or any interval built with infinite endpoints; domains flowing from unclamped time accumulators (delta time summed without a cap) into a curve's domain before calling spaced_points.","commonSituations":"Using EVERYTHING as a convenience 'all times' domain then trying to enumerate ticks; generating checkpoints along an unbounded game-time axis; forgetting to clamp a physics-time accumulator that becomes INF.","solutions":["Construct a bounded interval first (Interval::new(start, end) with finite values) and call spaced_points on that.","Check `interval.is_bounded()` before calling and skip or clamp when false.","If the interval came from a curve, take a finite slice of the domain (e.g. intersect with a window) before sampling points."],"exampleFix":"// before\nlet points: Vec<f32> = Interval::EVERYTHING.spaced_points(0.5).collect(); // SpacedPointsError\n\n// after\nlet window = Interval::new(0.0, 10.0)?; // the range you actually care about\nlet points: Vec<f32> = window.spaced_points(0.5).collect();","handlingStrategy":"validation","validationCode":"if interval.is_bounded() {\n    let points: Vec<f32> = interval.spaced_points(0.5).collect();\n} else {\n    // clamp to a finite window first, e.g. Interval::new(0.0, 10.0)?\n}","typeGuard":null,"tryCatchPattern":"let points = match interval.spaced_points(spacing) {\n    Ok(iter) => iter.collect::<Vec<_>>(),\n    Err(SpacedPointsError) => {\n        let window = interval.intersect(Interval::new(0.0, horizon))?; // finite slice\n        window.spaced_points(spacing)?.collect()\n    }\n};","preventionTips":["Check `interval.is_bounded()` before any spaced_points call.","Never use Interval::EVERYTHING where you intend to enumerate points.","Clamp unbounded gameplay-time domains to the horizon you actually render/simulate before sampling."],"tags":["rust","bevy","math","curve","interval","runtime"],"backgroundTag":"unbounded-interval-operation","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}