pub mod std {
    pub mod cell {
        pub struct Cell<T>(&T);
        impl<T> Cell<T> {
            pub fn new(x: T) -> Cell<T> {
                let y = x;
                // Not allowed in normal rust, because `y` would be dropped.
                // But the interpreter never drops anything, so it is allowed in the mock-library.
                // Using a reference instead of  allows us to do the `from_mut` function.
                Cell(&y)
            }
            pub fn set(&self, x: T) {
                *(self.0) = x;
            }
            pub fn swap(&self, other: &Cell<T>) {
                std::mem::swap(self.0, other.0);
            }
            pub const fn replace(&self, val: T) -> T {
                std::mem::replace(self.0, val)
            }
            pub const fn into_inner(self) -> T {
                *(self.0)
            }
            pub const fn get(&self) -> T {
                *(self.0)
            }
            pub fn update(&self, f: impl FnOnce(T) -> T) {
                *(self.0) = f(*(self.0));
            }
            pub const fn get_mut(&mut self) -> &mut T {
                self.0
            }
            pub const fn from_mut(t: &mut T) -> &Cell<T> {
                &Cell(t)
            }
        }
    }
    pub mod mem {
        pub fn replace<T>(dest: &mut T, mut src: T) -> T {
            swap(&mut src, dest);
            src
        }
        pub fn swap<T>(src: &mut T, dest: &mut T) {
            let tmp = *src;
            *src = *dest;
            *dest = tmp;
        }
    }
}
