# Prevent using integer initializers that can generate runtime errors

**URL:** <https://forums.swift.org/t/prevent-using-integer-initializers-that-can-generate-runtime-errors/75467>\
**Category:** Using Swift\
**Created:** [October 18, 2024, 9:15pm UTC](https://forums.swift.org/t/prevent-using-integer-initializers-that-can-generate-runtime-errors/75467 "2024-10-18T21:15:50Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![kainjow](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/kainjow/32/32380_2.png) [@kainjow](https://forums.swift.org/u/kainjow)\
**Post date:** [December 15, 2024, 5:31am UTC](https://forums.swift.org/t/prevent-using-integer-initializers-that-can-generate-runtime-errors/75467/3 "2024-12-15T05:31:29Z")

</div>

I was thinking along the lines of how Rust does it, where (as far as I know) there is no safe way to convert a i32 to u32, but it has [try\_from](https://doc.rust-lang.org/std/primitive.u32.html#method.try_from-9) which can fail, yet for u32 -\> u64 they have [from](https://doc.rust-lang.org/std/primitive.u64.html#method.from-3) which cannot. There is no need to have special knowledge that a function could fail at runtime, unlike Swift, which has a combination of these functions. It seems like it could be a good fit alongside the [strict memory safety proposal](https://forums.swift.org/t/prospective-vision-optional-strict-memory-safety-for-swift/75090) potentially.

---

_[View the full topic](https://forums.swift.org/t/prevent-using-integer-initializers-that-can-generate-runtime-errors/75467)._
