Skip to content

Bug in RawOccupiedEntryMut::get_key_value #337

Closed
@JustForFun88

Description

@JustForFun88

Does this seem like a bug, or am I missing something? There is no need for mutable borrowing here.

impl<'a, K, V, S, A: Allocator + Clone> RawOccupiedEntryMut<'a, K, V, S, A> {
    /// Gets a reference to the key and value in the entry.
    #[cfg_attr(feature = "inline-more", inline)]
    pub fn get_key_value(&mut self) -> (&K, &V) {
        unsafe {
            let &(ref key, ref value) = self.elem.as_ref();
            (key, value)
        }
    }
}

I noticed it when I wrote an example for this function, and the compiler: make the variable mutable! Me: wait, what😂?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions