logoalt Hacker News

steeleduncantoday at 3:04 PM1 replyview on HN

    const MAX: u32 = 100;  // Compile-time constant
    let x: u32 = 10;       // Cannot be changed
If x cannot be changed, how does it differ (meaningfully) from a compile time constant in a safe language, ie in a case of no raw pointers

Replies

v0id_isgoodtoday at 3:18 PM

const can be used in places that need a compile-time-known value (like a fixed array size). let can't, even if it obviously holds a fixed number.