Skip to content

Word30210/feat add option from constructor#13

Merged
Word30210 merged 2 commits into
mainfrom
word30210/feat-add-option-from-constructor
May 22, 2026
Merged

Word30210/feat add option from constructor#13
Word30210 merged 2 commits into
mainfrom
word30210/feat-add-option-from-constructor

Conversation

@Word30210
Copy link
Copy Markdown
Contributor

@Word30210 Word30210 commented May 22, 2026

What

  • Add a new from constructor to src/std/option/init.luau that returns None when the given value is nil, otherwise wraps it in Some<T>.
  • Export from from the Option module.
  • Add test cases for .from in tests/std/option/.spec.luau (covers both the Some and None paths, plus Option.is checks).
  • Add a type-level check for Option.from in tests/std/option/.check.luau.

Why

Option.from provides an ergonomic way to lift a possibly-nil Luau value into an Option<T>, mirroring Rust's idiom of converting nullable values into Option. Without it, callers have to branch on nil manually before constructing Some/None.

Checklist

Required

  • lute run ./scripts/checker.luau -- ./src ./tests ./scripts passes
  • lute run ./scripts/tester.luau passes

Closes #12.

Functional Validation

  • Tests cover the changed behavior (.spec.luau and/or .check.luau added or updated)
  • Both happy and edge paths verified where applicable

Configuration & Docs

  • User-facing docs were updated where applicable (README.md / README.ko.md / CLAUDE.md)
  • New dependencies / configuration are reflected in pesde.toml / mise.toml
  • No sensitive values or credentials were introduced

If Applicable

  • Breaking type-surface or API changes are clearly described in this PR

@Word30210 Word30210 self-assigned this May 22, 2026
@Word30210 Word30210 added the enhancement New feature or request label May 22, 2026
@Word30210 Word30210 merged commit 135da98 into main May 22, 2026
2 checks passed
@Word30210 Word30210 deleted the word30210/feat-add-option-from-constructor branch May 22, 2026 07:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Option.from constructor for nullable values

1 participant