diff --git a/README.md b/README.md index 75ddd70..e7c9472 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Compile-time assertions for Rust, brought to you by [Nikolai Vazquez](https://twitter.com/NikolaiVazquez). -This library lets you ensure correct assumptions about constants, types, and +This library lets you ensure assumptions about constants, types, and more. See the [docs] and [FAQ](#faq) for more info! ## Installation @@ -70,12 +70,12 @@ This crate exposes the following macros: - **Q:** When would I want to use this? - **A:** This library is useful for when wanting to ensure properties of + **A:** This library is useful when wanting to ensure properties of constants, types, and traits. Basic examples: - - With the release of 1.39, `str::len` can be called in a `const` + - With the release of Rust 1.39, `str::len` can be called in a `const` context. Using [`const_assert!`], one can check that a string generated from elsewhere is of a given size: @@ -114,7 +114,7 @@ This crate exposes the following macros: - **Q:** Will this affect my compiled binary? **A:** Nope! There is zero runtime cost to using this because all checks are - at compile-time, and so no code is emitted to run. + at compile-time, so no code is emitted to run. - **Q:** Will this affect my compile times? diff --git a/src/assert_align.rs b/src/assert_align.rs index f1de642..9ef160d 100644 --- a/src/assert_align.rs +++ b/src/assert_align.rs @@ -20,7 +20,7 @@ /// ``` /// /// The following example fails to compile because `i32x4` explicitly has 4 -/// times the alignment as `[i32; 4]`: +/// times the alignment of `[i32; 4]`: /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} diff --git a/src/assert_impl.rs b/src/assert_impl.rs index 83545ca..f126140 100644 --- a/src/assert_impl.rs +++ b/src/assert_impl.rs @@ -163,7 +163,7 @@ macro_rules! assert_impl_any { /// /// Note that the combination of all provided traits is required to not be /// implemented. If you want to check that none of multiple traits are -/// implemented you should invoke [`assert_impl_not_any!`] instead. +/// implemented, you should invoke [`assert_impl_not_any!`] instead. /// /// # Examples /// @@ -233,7 +233,7 @@ macro_rules! assert_not_impl_all { /// /// This macro causes a compilation failure if any of the provided individual /// traits are implemented for the type. If you want to check that a combination -/// of traits is not implemented you should invoke [`assert_impl_not_all!`] +/// of traits is not implemented, you should invoke [`assert_impl_not_all!`] /// instead. For single traits both macros behave the same. /// /// # Examples diff --git a/src/assert_obj_safe.rs b/src/assert_obj_safe.rs index ecbba96..84646e7 100644 --- a/src/assert_obj_safe.rs +++ b/src/assert_obj_safe.rs @@ -2,9 +2,9 @@ /// Asserts that the traits support dynamic dispatch /// ([object-safety](https://doc.rust-lang.org/book/ch17-02-trait-objects.html#object-safety-is-required-for-trait-objects)). /// -/// This is useful for when changes are made to a trait that accidentally +/// This is useful when changes are made to a trait that accidentally /// prevent it from being used as an [object]. Such a case would be adding a -/// generic method and forgetting to add `where Self: Sized` after it. If left +/// generic method and forgetting to add `where Self: Sized`. If left /// unnoticed, that mistake will affect crate users and break both forward and /// backward compatibility. /// @@ -36,14 +36,6 @@ /// assert_obj_safe!(inner::BasicTrait); /// ``` /// -/// The following example fails to compile because raw pointers cannot be sent -/// between threads safely: -/// -/// ```compile_fail -/// # #[macro_use] extern crate static_assertions; fn main() {} -/// assert_impl!(*const u8, Send); -/// ``` -/// /// The following example fails to compile because generics without /// `where Self: Sized` are not allowed in [object-safe][object] trait methods: /// @@ -71,6 +63,6 @@ #[macro_export] macro_rules! assert_obj_safe { ($($xs:path),+ $(,)?) => { - $(const _: Option<&$xs> = None;)+ + $(const _: Option<&dyn $xs> = None;)+ }; } diff --git a/src/assert_size.rs b/src/assert_size.rs index e1a7067..62562cc 100644 --- a/src/assert_size.rs +++ b/src/assert_size.rs @@ -6,7 +6,7 @@ /// /// # Alternatives /// -/// There also exists [`assert_size_eq_val`](macro.assert_size_eq_val.html) and +/// There also exist [`assert_size_eq_val`](macro.assert_size_eq_val.html) and /// [`assert_size_eq_ptr`](macro.assert_size_eq_ptr.html). Instead of specifying /// types to compare, values' sizes can be directly compared against each other. /// @@ -39,7 +39,7 @@ macro_rules! assert_size_eq { }; } -/// Asserts that types are equal in alignment. +/// Asserts that types are equal in size. /// /// This macro has been deprecated in favor of /// [`assert_size_eq!`](macro.assert_size_eq.html). @@ -58,8 +58,8 @@ macro_rules! assert_eq_size { /// /// # Examples /// -/// This especially is useful for when coercing pointers between different types -/// and ensuring the underlying values are the same size. +/// This especially is useful when coercing between pointers to different types +/// and ensuring the underlying values have the same size. /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} @@ -152,7 +152,7 @@ macro_rules! assert_size_eq_val { } } -/// Asserts that values pointed to are equal in size. +/// Asserts that values are equal in size. /// /// This macro has been deprecated in favor of /// [`assert_size_eq_val!`](macro.assert_size_eq_val.html). diff --git a/src/assert_trait.rs b/src/assert_trait.rs index 5c87ce6..f3b138b 100644 --- a/src/assert_trait.rs +++ b/src/assert_trait.rs @@ -1,4 +1,4 @@ -/// Asserts that the trait is a child of all of the other traits. +/// Asserts that the trait is a subtrait of all of the other traits. /// /// Related: /// - [`assert_trait_super_all!`] @@ -43,14 +43,14 @@ macro_rules! assert_trait_sub_all { }; } -/// Asserts that the trait is a parent of all of the other traits. +/// Asserts that the trait is a supertrait of all of the other traits. /// /// Related: /// - [`assert_trait_sub_all!`] /// /// # Examples /// -/// With this, traits `A` and `B` can both be tested to require [`Copy`] on a +/// With this, traits `A` and `B` can both be tested to require [`Copy`] in a /// single line: /// /// ``` @@ -94,7 +94,7 @@ macro_rules! assert_trait_super_all { }; } -/// Asserts that the trait is a child of one or more of the other traits. +/// Asserts that the trait is a subtrait of one or more of the other traits. /// /// Related: /// - [`assert_impl_any!`] diff --git a/src/const_assert.rs b/src/const_assert.rs index 39ad3eb..a8e06f8 100644 --- a/src/const_assert.rs +++ b/src/const_assert.rs @@ -1,12 +1,12 @@ /// Asserts that constant expressions evaluate to `true`. /// /// Constant expressions can be ensured to have certain properties via this -/// macro If the expression evaluates to `false`, the file will fail to compile. -/// This is synonymous to [`static_assert` in C++][static_assert]. +/// macro. If the expression evaluates to `false`, the module will fail to compile. +/// This is similar to [`static_assert` in C++][static_assert]. /// /// # Alternatives /// -/// There also exists [`const_assert_eq`](macro.const_assert_eq.html) for +/// There also exist [`const_assert_eq`](macro.const_assert_eq.html) for /// validating whether a sequence of expressions are equal to one another. /// /// # Examples @@ -72,7 +72,7 @@ macro_rules! const_assert { /// const_assert_eq!(TWO * TWO, TWO + TWO); /// ``` /// -/// Just because 2 × 2 = 2 + 2 doesn't mean it holds true for other numbers: +/// Just because 2 × 2 = 2 + 2, doesn't mean it holds true for other numbers: /// /// ```compile_fail /// # #[macro_use] extern crate static_assertions; fn main() {} @@ -164,7 +164,7 @@ macro_rules! const_assert_gt { }; } -/// Asserts that constants are less than or equal to each other. +/// Asserts that constants are greater than or equal to each other. #[macro_export(local_inner_macros)] macro_rules! const_assert_ge { ($x:expr, $($y:expr),+ $(,)?) => { diff --git a/src/does_impl.rs b/src/does_impl.rs index f2d35fe..0833cfd 100644 --- a/src/does_impl.rs +++ b/src/does_impl.rs @@ -2,7 +2,7 @@ /// /// # Examples /// -/// One can mimic `assert_impl!` using this macro: +/// One can mimic `assert_impl!` using the following: /// /// ``` /// # #[macro_use] extern crate static_assertions; fn main() {} diff --git a/src/lib.rs b/src/lib.rs index aa7e227..0040e9c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,7 +11,7 @@ //!

//! //! -//! Assertions to ensure correct assumptions about constants, types, and more. +//! Assertions to ensure assumptions about constants, types, and more. //! //! _All_ checks provided by this crate are performed at [compile-time]. This //! allows for finding errors quickly and early when it comes to ensuring @@ -38,19 +38,19 @@ //! # fn main() {} //! ``` //! -//! When using [Rust 2018 edition][2018], the following shorthand can help if +//! When using the [Rust 2018 edition][2018], the following shorthand can help if //! having `#[macro_use]` is undesirable. //! //! ```edition2018 -//! extern crate static_assertions as sa; +//! use static_assertions::const_assert; //! -//! sa::const_assert!(true); +//! const_assert!(true); //! ``` //! //! ## Procedural Extensions //! -//! As an extension crate [`proc_static_assertions`] adds a number of new -//! assertions to this. These are implemented as [procedural macros], hence the +//! As an extension crate, [`proc_static_assertions`] adds a number of new +//! assertions. These are implemented as [procedural macros], hence the //! "proc" prefix. As a result, they have a bit more visibility over what's //! being asserted over than normal macros would. //!