This review is from Crev, a distributed system for code reviews. To add your review, set up cargo-crev.

0.2.0 (current) Rating: Positive Thoroughness: Medium Understanding: High

by yvt on 2021-10-03

This crate provides a trait to specify a type's default value by an associated constant.

It provides trait implementations for types from std, which are mostly reasonable. Some are just const version of their respective Default implementation. MaybeUninit and Result are the counterexamples, where opinionated decisions are made. To elaborate, MaybeUninit<T>'s default value could be Self::uninit() or Self::new(T::default()). So the standard library chooses neither, whereas this crate implements Constdef using the former. The users of this crate (particularly its derive macro) might want to watch out for such cases and check that intended default values are indeed created.

This crate re-exports a procedural macro from const_internals, which is not covered by this review.


Lib.rs has been able to verify that all files in the crate's tarball are in the crate's repository. Please note that this check is still in beta, and absence of this confirmation does not mean that the files don't match.

Crates in the crates.io registry are tarball snapshots uploaded by crates' publishers. The registry is not using crates' git repositories, so there is a possibility that published crates have a misleading repository URL, or contain different code from the code in the repository.

To review the actual code of the crate, it's best to use cargo crev open constant. Alternatively, you can download the tarball of constant v0.2.0 or view the source online.