Intellij-rust: Add postfix templates for Result/Option wrapping

Created on 3 Jun 2020  路  3Comments  路  Source: intellij-rust/intellij-rust

When you write functions that return Result or Option, it's very common to write out full expression first and then wrap it in Ok($expr) and alike. It would be great to have postfix templates for these operations.

Specifically:

  • $expr.ok<caret> expand to Ok($expr)
  • $expr.err<caret> expand to Err($expr)
  • $expr.some<caret> expand to Some($expr)
  • $expr.none<caret> expand to None($expr)
feature help wanted 褋ompletion

Most helpful comment

This seems like a pretty easy task, so I am gonna give it a shot. I wanted to start contrubuting at some point anyway ;)

All 3 comments

$expr.none expand to None($expr)

Probably, did you mean something else? Option::None doesn't have any fields

@Undin Oh, right, I didn't think about it 馃槃 nevermind that case then.

This seems like a pretty easy task, so I am gonna give it a shot. I wanted to start contrubuting at some point anyway ;)

Was this page helpful?
0 / 5 - 0 ratings