We can use the compiler to prove that something implements Copy. Using the list of primitives from the Rust programming language :
fn is_copy<T: Copy>() {}
fn main() {
is_copy::<bool>();
is_copy::<char>();
is_copy::<i8>();
is_copy::<i16>();
is_copy::<i32>();
is_copy::<i64>();
is_copy::<u8>();
is_copy::<u16>();
is_copy::<u32>();
is_copy::<u64>();
is_copy::<isize>();
is_copy::<usize>();
is_copy::<f32>();
is_copy::<f64>();
is_copy::<fn()>();
}
There are several other types that I would consider "primitive":
- Fixed links (
&T) - Volatile Links (
&mut T) - Raw Pointers (
*const T/ *mut T)
Copy, Copy, Copy:
is_copy::<&String>();
is_copy::<*const String>();
is_copy::<*mut String>();
is_copy::<&mut i32>();
:
; . Copy, Copy:
is_copy::<[i32; 1]>();
is_copy::<(i32, i32)>();
is_copy::<[Vec<i32>; 1]>();
is_copy::<(Vec<i32>, Vec<i32>)>();
. ([T]) (str) . - , (&[T]/&str). . , .
is_copy::<&str>();
is_copy::<&[i32]>();
is_copy::<str>();
is_copy::<[i32]>();
, , , . ( , ).