Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-assists/src/handlers/replace_arith_with_checked.rs')
| -rw-r--r-- | crates/ide-assists/src/handlers/replace_arith_with_checked.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/crates/ide-assists/src/handlers/replace_arith_with_checked.rs b/crates/ide-assists/src/handlers/replace_arith_with_checked.rs index 419b6febf1..ff1fba5818 100644 --- a/crates/ide-assists/src/handlers/replace_arith_with_checked.rs +++ b/crates/ide-assists/src/handlers/replace_arith_with_checked.rs @@ -1,10 +1,22 @@ use crate::assist_context::{AssistContext, Assists}; use crate::utils::{replace_arith, ArithKind}; -pub(crate) fn replace_arith_with_checked( - acc: &mut Assists, - ctx: &AssistContext<'_>, -) -> Option<()> { +// Assist: replace_arith_with_checked +// +// Replaces arithmetic on integers with the `checked_*` equivalent. +// +// ``` +// fn main() { +// let x = 1 $0+ 2; +// } +// ``` +// -> +// ``` +// fn main() { +// let x = 1.checked_add(2); +// } +// ``` +pub(crate) fn replace_arith_with_checked(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> { replace_arith(acc, ctx, ArithKind::Checked) } |