{"record":{"id":"3b2dffbebeb62290","repo":"bevyengine/bevy","slug":"expected-mutable-reference-value","errorCode":null,"errorMessage":"expected mutable reference value","messagePattern":"expected mutable reference value","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_reflect/src/func/return_type.rs","lineNumber":66,"sourceCode":"    /// # Panics\n    ///\n    /// Panics if the return value is not [`Self::Ref`].\n    pub fn unwrap_ref(self) -> &'a dyn PartialReflect {\n        match self {\n            Return::Ref(value) => value,\n            _ => panic!(\"expected reference value\"),\n        }\n    }\n\n    /// Unwraps the return value as a mutable reference to a value.\n    ///\n    /// # Panics\n    ///\n    /// Panics if the return value is not [`Self::Mut`].\n    pub fn unwrap_mut(self) -> &'a mut dyn PartialReflect {\n        match self {\n            Return::Mut(value) => value,\n            _ => panic!(\"expected mutable reference value\"),\n        }\n    }\n}\n\n/// A trait for types that can be converted into a [`Return`] value.\n///\n/// This trait exists so that types can be automatically converted into a [`Return`]\n/// by [`ReflectFn`] and [`ReflectFnMut`].\n///\n/// This trait is used instead of a blanket [`Into`] implementation due to coherence issues:\n/// we can't implement `Into<Return>` for both `T` and `&T`/`&mut T`.\n///\n/// This trait is automatically implemented for non-reference types when using the `Reflect`\n/// [derive macro]. Blanket impls cover `&T` and `&mut T`.\n///\n/// [`ReflectFn`]: crate::func::ReflectFn\n/// [`ReflectFnMut`]: crate::func::ReflectFnMut\n/// [derive macro]: derive@crate::Reflect","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_reflect/src/func/return_type.rs#L48-L84","documentation":"Panic raised by Return::unwrap_mut when the wrapped Return value is not the Return::Mut variant. The caller asserted a mutable-reference return that does not exist (the value is Owned or a shared Ref), violating unwrap_mut's precondition; a shared reference cannot be safely re-borrowed as mutable.","triggerScenarios":"Thrown at crates/bevy_reflect/src/func/return_type.rs:66 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check Return::is_mut() before unwrapping","Ensure the function returns a mutable reference variant before calling unwrap_mut"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}