Comment

Comment by m-ou-se

An important one is missing from this overview: using a const. This is sometimes useful, because it does not require the type to be Copy; only that the value is a constant:

    const EMPTY: String = String::new();
    let a: [String; 1000] = [EMPTY; 1000];

    const NONE: Option<String> = None;
    let b: [Option<String>; 1000] = [NONE; 1000];

    const SEVEN: AtomicU32 = AtomicU32::new(7);
    let c: [AtomicU32; 200] = [SEVEN; 200];
parent m-ou-se 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton