Skip to content

book: add question mark operator#601

Merged
GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom
VojtaStanek:book-questionmark
Sep 27, 2025
Merged

book: add question mark operator#601
GuillaumeGomez merged 1 commit intoaskama-rs:masterfrom
VojtaStanek:book-questionmark

Conversation

@VojtaStanek
Copy link
Copy Markdown
Contributor

fix #598

Comment thread book/src/template_syntax.md Outdated
### Question mark operator

You can use the `?` operator similarly as [`?` operator in Rust] when
handling `Result` types.
Copy link
Copy Markdown
Collaborator

@GuillaumeGomez GuillaumeGomez Sep 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
handling `Result` types.
handling types implementing the `Try` trait (like `Result` and `Option`). Example:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah nevermind. It only works with Result. So instead what do you think about:

Suggested change
handling `Result` types.
You can use the `?` operator similarly as [`?` operator in Rust] but only on `Result` types.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 updated.

@GuillaumeGomez
Copy link
Copy Markdown
Collaborator

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit a299ed4 into askama-rs:master Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mention try expression in docs

2 participants