Skip to content

Support Rust-like .unwrap() and .is_some() #212

@schoen

Description

@schoen

Project

compiler

Describe the feature

(Capturing a feature request from a developer interview.)

In Rust, you can .unwrap() an option type, causing your program to crash if the option type value is None. We have unwrap() as a library function with the same behavior, but experienced Rust programmers may expect to have this available as a method on the underlying object.

Rust also has .is_some() to check (as a boolean value) whether the specified option type value is present (i.e., Some()). This is also very easy to implement as a library function, but Rust programmers may again expect to have this available as a method on the object.

If we emphasize the claim of similarity to Rust, we may want to see how far we can take that similarity in terms of providing convenient syntactic sugar corresponding to Rust in cases where SimplicityHL would be technically capable of supporting it (of course, it isn't always possible!).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions