{"record":{"id":"d3114ed6acae048e","repo":"emilk/egui","slug":"vec2-index-out-of-bounds-index","errorCode":null,"errorMessage":"Vec2 index out of bounds: {index}","messagePattern":"Vec2 index out of bounds: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/emath/src/vec2.rs","lineNumber":333,"sourceCode":"    #[must_use]\n    #[inline]\n    pub fn clamp(self, min: Self, max: Self) -> Self {\n        Self {\n            x: self.x.clamp(min.x, max.x),\n            y: self.y.clamp(min.y, max.y),\n        }\n    }\n}\n\nimpl core::ops::Index<usize> for Vec2 {\n    type Output = f32;\n\n    #[inline(always)]\n    fn index(&self, index: usize) -> &f32 {\n        match index {\n            0 => &self.x,\n            1 => &self.y,\n            _ => panic!(\"Vec2 index out of bounds: {index}\"),\n        }\n    }\n}\n\nimpl core::ops::IndexMut<usize> for Vec2 {\n    #[inline(always)]\n    fn index_mut(&mut self, index: usize) -> &mut f32 {\n        match index {\n            0 => &mut self.x,\n            1 => &mut self.y,\n            _ => panic!(\"Vec2 index out of bounds: {index}\"),\n        }\n    }\n}\n\nimpl PartialEq for Vec2 {\n    #[track_caller]\n    #[inline]","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/emilk/egui/blob/1a9d2af9efde043883036a6c0fc52423df435398/crates/emath/src/vec2.rs#L315-L351","documentation":"Error \"Vec2 index out of bounds: {index}\" thrown in emilk/egui.","triggerScenarios":"Thrown at crates/emath/src/vec2.rs:333 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Index a Vec2 only with 0 (x) or 1 (y); use v.x / v.y directly instead of indexing."],"exampleFix":"let value = match index { 0 => v.x, 1 => v.y, _ => return };","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1a9d2af9efde043883036a6c0fc52423df435398","analyzedAt":"2026-08-19T12:39:57.743Z","contentChangedAt":"2026-08-19T12:39:57.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}