What does ~ means in Rust?

I would very much appreciate if someone tell me what does ~ means in Rust. I have not yet came upon it in TRPL book but in std for example in Struct std::boxed::Box we see:

pub const fn new_in(x: T, alloc: A) -> Self
    where
        A: ~const Allocator + ~const Destruct,
    {
        let mut boxed = Self::new_uninit_in(alloc);
        unsafe {
            boxed.as_mut_ptr().write(x);
            boxed.assume_init()
        }
    }

Thanks.

1 Like

This is an unstable syntax (only works on nightly Rust or in the standard library with the appropriate feature gate enabled) that means that the new_in function is const only if type parameter A's implementation of the Allocator and Destruct traits uses only const fns. This feature will eventually be available in stable Rust as well, but the design is not yet finalized.

(Also, such questions are more appropriate for the Users forum.)