Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on C2Rust: translate C into Rust code. Parent comment
It's also explicitly typing everything, which increases verbosity.
The "clean" rust conversion would look something like this:
fn insertion_sort<T: Copy + Ord>(p: &mut [T]) { for i in 1..p.len() { let x = p[i]; let mut j = i; while j > 0 && p[j-1] > x { p[j] = p[j-1]; j -= 1; } p[j] = x; } }
fn insertion_sort<T: Ord>(p: &mut [T]) { for i in 0..p.len() { for j in (0..i).rev() { if p[j] < p[j + 1] { break } p.swap(j, j + 1); } } }
There are no comments on this comment yet.
It's also explicitly typing everything, which increases verbosity.
The "clean" rust conversion would look something like this:
Although unless it's really necessary I would expect the simpler version: