emilk/egui · error
Vec2 index out of bounds: {index}
Error message
Vec2 index out of bounds: {index} What it means
Error "Vec2 index out of bounds: {index}" thrown in emilk/egui.
Source
Thrown at crates/emath/src/vec2.rs:333
#[must_use]
#[inline]
pub fn clamp(self, min: Self, max: Self) -> Self {
Self {
x: self.x.clamp(min.x, max.x),
y: self.y.clamp(min.y, max.y),
}
}
}
impl core::ops::Index<usize> for Vec2 {
type Output = f32;
#[inline(always)]
fn index(&self, index: usize) -> &f32 {
match index {
0 => &self.x,
1 => &self.y,
_ => panic!("Vec2 index out of bounds: {index}"),
}
}
}
impl core::ops::IndexMut<usize> for Vec2 {
#[inline(always)]
fn index_mut(&mut self, index: usize) -> &mut f32 {
match index {
0 => &mut self.x,
1 => &mut self.y,
_ => panic!("Vec2 index out of bounds: {index}"),
}
}
}
impl PartialEq for Vec2 {
#[track_caller]
#[inline]View on GitHub (pinned to 1a9d2af9ef)
Solutions
- Index a Vec2 only with 0 (x) or 1 (y); use v.x / v.y directly instead of indexing.
Example fix
let value = match index { 0 => v.x, 1 => v.y, _ => return }; When it happens
Trigger: Thrown at crates/emath/src/vec2.rs:333 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of emilk/egui@1a9d2af9ef (2026-08-19).
Data as JSON: /api/errors/d3114ed6acae048e.
Report an issue: GitHub.