Hacker News new | ask | show | jobs
by kelnos 443 days ago
> I am trying to use safe `From::from` instead. However, this is a bit noisy: `usize::from(n)` vs `n as usize`.

If there's enough information in the surrounding code for type inference to do its thing, you can shorten it to `n.into()`.

1 comments

Another limitation I face is the impossibility of using `usize::from(n)` in `const` context.