lean/rust style if let #34

Open
opened 2026-07-01 11:28:41 +02:00 by st · 0 comments
Owner

a function that recognizes string elements and extracts their contents can be written:

def Inline.string? (inline : Inline) : Option String :=
  match inline with
  | Inline.string s => some s
  | _ => none

An alternative way of writing this function's body uses if together with let:

def Inline.string? (inline : Inline) : Option String :=
  if let Inline.string s := inline then
    some s
  else none
> a function that recognizes string elements and extracts their contents can be written: > > ``` > def Inline.string? (inline : Inline) : Option String := > match inline with > | Inline.string s => some s > | _ => none > ``` > > An alternative way of writing this function's body uses if together with let: > > ``` > def Inline.string? (inline : Inline) : Option String := > if let Inline.string s := inline then > some s > else none > ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
st/amelie#34
No description provided.