{"record":{"id":"d3561ccef759a89c","repo":"DioxusLabs/dioxus","slug":"const-vec-index-out-of-bounds","errorCode":null,"errorMessage":"const vec index out of bounds","messagePattern":"const vec index out of bounds","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dioxus-const-vec/src/lib.rs","lineNumber":211,"sourceCode":"    /// assert_eq!(ONE.get(0), Some(&1));\n    /// ```\n    pub const fn get(&self, index: usize) -> Option<&T> {\n        if index < self.len as usize {\n            Some(unsafe { &*self.memory[index].as_ptr() })\n        } else {\n            None\n        }\n    }\n\n    /// Get a copy of the value at the given index.\n    ///\n    /// This panics if `index` is out of bounds.\n    pub const fn at(&self, index: usize) -> T\n    where\n        T: Copy,\n    {\n        if index >= self.len as usize {\n            panic!(\"const vec index out of bounds\");\n        }\n        unsafe { self.memory[index].assume_init() }\n    }\n\n    /// Get the length of the [`ConstVec`].\n    ///\n    /// # Example\n    ///\n    /// ```rust\n    /// # use dioxus_const_vec::ConstVec;\n    /// const ONE: ConstVec<u8> = {\n    ///     let mut vec = ConstVec::new();\n    ///     vec.push(1);\n    ///     vec\n    /// };\n    /// assert_eq!(ONE.len(), 1);\n    /// ```\n    pub const fn len(&self) -> usize {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/dioxus-const-vec/src/lib.rs#L193-L229","documentation":"`ConstVec::at` panics when the requested index is >= the vec's length. Unlike `get`, which returns Option, `at` is an unchecked-style accessor for const contexts where the caller must guarantee the index is valid; firing means the caller indexed past the elements stored in the const vec.","triggerScenarios":"Thrown at packages/dioxus-const-vec/src/lib.rs:211 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use an index smaller than the const vec length; check bounds before indexing."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}