# unnecessary-fallible-conversion

Simplify fallible integer conversions that cannot fail

A fallible integer conversion adds an undefined case when the source type always fits the destination.
Instead, you SHOULD remove identity conversions and use `as` for lossless widening conversions.

- Category: style
- Level: warning
- Fix: automatic
- Scope: module

## Reported

```ds title="main.ds"
function widen(value: int32): int64 | undefined {
    return value.tryInto<int64>();
}
```

## Accepted

```ds title="main.ds"
function widen(value: int32): int64 | undefined {
    return value as int64;
}
```

## Prior art

- [Clippy · unnecessary_fallible_conversions](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_fallible_conversions)

[language/linter/src/rules/style/unnecessary_fallible_conversion.rs:8](https://github.com/destack-sh/destack/blob/main/language/linter/src/rules/style/unnecessary_fallible_conversion.rs#L8)
