News for hackers. Stuff that matters.
Re:Rust explained using easy English by joshmarlow on Thursday July 23, 2020 @12:53PM (#23929346)
>third party libraries (even extremely popular ones) have outdated example code or docs that are inconsistent with actually released versions.

That's actually one of my big pet-peeves about OSS. This is especially annoying because the Rust ecosystem already has a really nice solution to the problem - skeptic ([0]).

Skeptic finds Rust snippets in markdown files and dynamically builds tests to run them. So if your docs go out of sync with your code, `cargo test` fails.

[0] - https://github.com/brson/rust-skeptic

Re:Rust explained using easy English by giancarlostoro on Thursday July 23, 2020 @03:14PM (#23931116)
Kinda sad it looks like that was last updated 2 years ago
Re:Rust explained using easy English by masklinn on Friday July 24, 2020 @03:09PM (#23943336)
skeptic should only be useful for arbitrary markdown files though, `cargo test` should run the docstring snippets. The example snippets are more difficult to craft though, as they need to be "self-contained" and you need to hide the bits you don't want to show by marking them as a pseudo-comment using `#`. Rustdoc also has a `--test` flag.

Tested it on clap (no specific reason, just have a checkout locally) and it ran 314 snippets from the docs so seems to work.

Re:Rust explained using easy English by giancarlostoro on Monday July 27, 2020 @09:55AM (#23965104)
My main concern is if Rust changes significantly in a few years and this utility breaks then.
Re:Rust explained using easy English by joshmarlow on Tuesday July 28, 2020 @10:16AM (#23976008)
That's a reasonable concern. IMO, a tool like Skeptic would add a lot of value to the ecosystem if deployed widely. It would be really cool if something equivalent was integrated into cargo.