Skip to content

Str.len and most string functions return Option when they can't fail #29

Description

@NightmarePog

`Str.len`, `Str.upper`, `Str.lower`, `Str.sub`, and several others are declared as returning `Option` because they wrap Lua externs that could theoretically return nil — but for these specific functions with valid inputs, they never do.

The result is that every call inside the stdlib itself ends with `.unwrap_or(0)` or `.unwrap_or("")`, which is noise. Callers have to unwrap values that will never be `None`.

These functions should return their concrete type directly. The `Option` wrapper should only be kept for functions that genuinely return nil for valid inputs (like `Str.find`, which returns `None` when the substring isn't found).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions