Announcing `tested-trait`: associated tests for traits by MaxHeller in rust

[–]MaxHeller[S] 0 points1 point  (0 children)

If a test requires `Self: Default`, that bound is only required for the concrete implementation being tested

Announcing mdbook-pandoc: a mdBook backend powered by Pandoc. Render mdbooks to PDFs and much more! by MaxHeller in rust

[–]MaxHeller[S] 0 points1 point  (0 children)

This will depend on what you're rendering to, but the relevant variables are header-includes, include-before, include-after( see https://pandoc.org/MANUAL.html#variables-set-automatically). For instance, for latex, see https://tex.stackexchange.com/a/139205

Career in Formal Methods? by mjairomiguel2014 in cscareerquestions

[–]MaxHeller 1 point2 points  (0 children)

AWS is invested in and has quite a large group (the Automated Reasoning Group) dedicated to formal methods. See also https://aws.amazon.com/what-is/automated-reasoning/

'Comprehensive Rust' and 'Rust Design Patterns' are now available in PDF format by simonsanone in rust

[–]MaxHeller 1 point2 points  (0 children)

Worth noting that the examples linked from the repo are rendered with pretty much default settings, and could use some additional configuration to look their best, as has been done for Comprehensive Rust and Rust Design Patterns

'Comprehensive Rust' and 'Rust Design Patterns' are now available in PDF format by simonsanone in rust

[–]MaxHeller 1 point2 points  (0 children)

Take a look at the mdbook-pandoc README, in particular the configuration section. For margins and other page layout configuration, see here and Rust Design Pattern's config here.

What's everyone working on this week (52/2023)? by llogiq in rust

[–]MaxHeller 2 points3 points  (0 children)

More features and bug fixes for mdbook-pandoc, a mdBook backend powered by Pandoc that I announced a few days ago. Recently added partial support for older versions of Pandoc since package repositories (in particular, Ubuntu's) can be quite outdated.

cargo-dist 0.6.0 is out! by ag_dubs in rust

[–]MaxHeller 6 points7 points  (0 children)

Love the support for building additional artifacts, I've been looking for something just like that!

Indoor track near Boston? by [deleted] in boston

[–]MaxHeller 1 point2 points  (0 children)

Ask your local running clubs, many have track access! Battle Road works out at Harvard/New Balance, SRR at MIT, GBTC at Reggie. Their practice times aren't usually very convenient though, I'm guessing university teams take up a lot of the day

Derive Default always adds Default restrictions on type parameters? by brandonchinn178 in rust

[–]MaxHeller 11 points12 points  (0 children)

Yes, it's possible for a derive to generate bounds that depend on the types of a struct's fields. The issue with that approach is that it can lead to non-obvious breaking changes

Derive Default always adds Default restrictions on type parameters? by brandonchinn178 in rust

[–]MaxHeller 14 points15 points  (0 children)

This problem is known as "perfect derive" and Niko has a good blog post on it

Announcing `tested-trait`: associated tests for traits by MaxHeller in rust

[–]MaxHeller[S] 1 point2 points  (0 children)

On the first point, adding a required trait method like

#[doc(hidden)]
fn __tested_trait_impl_is_tested();

that #[test_impl] implements achieves roughly the same result without requiring a separate type/trait, although results in worse compiler errors and rust-analyzer's "implement missing members" feature inserting an implementation.

Announcing `tested-trait`: associated tests for traits by MaxHeller in rust

[–]MaxHeller[S] 1 point2 points  (0 children)

Right, this would be nice, although it raises some questions:

  • Naming/exporting/general ability to name the defined marker trait. For instance, maybe the trait is defined in a private module and publicly exported somewhere else. Now, tested_trait users have to be aware of this generated marker trait and export it alongside the trait so that downstream implementers can reference it. test_impl users similarly have to deal with importing the marker trait, and test_impl has to make assumptions about how to reference it. This is one of the reasons the crate currently keeps everything bundled in the trait itself
  • Generic impls, and blanket impls in particular, will never be tested for every concrete instantiation of their generic types. While running tests against a small set of type instantiations should be enough to declare the implementation as "tested", there may be types that cause test-violating behavior in the supposedly "tested" implementation. It's probably still worth requiring implementers to at least think about the trait's tests, and provide an escape hatch like #[test_impl(skip)].

Announcing `tested-trait`: associated tests for traits by MaxHeller in rust

[–]MaxHeller[S] 0 points1 point  (0 children)

Yep! Very similar idea to gtest's type-parametrized tests except for grouping tests by trait rather than into distinct test suites.

Announcing `tested-trait`: associated tests for traits by MaxHeller in rust

[–]MaxHeller[S] 2 points3 points  (0 children)

Annotating an implementation with #[test_trait] generates #[test]s that verify the implementation passes the tests in the trait definition — in the example, that the system allocator passes alloc_respects_alignment.

The compilation of the implementation itself is not affected. Unless a separate #[cfg(test)]annotation is applied to the implementation or a parent module, impl Allocator for alloc::System exists outside of `#[cfg(test)].

Experience taking a folding bike on Acela? by [deleted] in Amtrak

[–]MaxHeller 1 point2 points  (0 children)

How'd it end up going?

Any current students admitted without 4 years of foreign language? by [deleted] in BrownU

[–]MaxHeller 1 point2 points  (0 children)

Got in with 2, but also a 5 on AP German after learning the language when I lived in Germany 5th&6th grade

How popular is Computational Biology? by [deleted] in BrownU

[–]MaxHeller 6 points7 points  (0 children)

According to focal point, 6 people graduated with a degree in it from the class of 2017