E0492: Str fixed capacity exceeded
| Code | Category | Stability |
|---|---|---|
E0492 | Struct and enum | Permanent |
Explanation
Str(N) stores at most N UTF-8 bytes in its inline buffer. When a string literal's encoded byte length exceeds that fixed capacity, the value cannot be represented without truncation, so construction is rejected at compile time.
Likely cause
A literal assigned or passed as Str(N) is longer than N bytes. Increase the declared capacity, shorten the literal, or use the growable StrBuf type when the required capacity is not fixed.
Examples
Exceed a fixed string capacity
fn main() -> i32 {
let value: Str(3) = "hello";
@intCast(value.len())
}
Choose sufficient fixed capacity
fn main() -> i32 {
let value: Str(5) = "hello";
@intCast(value.len())
}