Skip to content

Commit f8134e2

Browse files
authored
[doc] Update wording regarding transmute macros (#1662)
1 parent 0003184 commit f8134e2

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

README.md

+8-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Zerocopy provides four derivable traits for zero-cost conversions:
4242
- `IntoBytes` indicates that a type may safely be converted *to* a byte
4343
sequence
4444

45-
This traits support sized types, slices, and [slice DSTs][slice-dsts].
45+
These traits support sized types, slices, and [slice DSTs][slice-dsts].
4646

4747
[slice-dsts]: KnownLayout#dynamically-sized-types
4848

@@ -61,7 +61,7 @@ You should generally derive these marker traits whenever possible.
6161

6262
###### Conversion Macros
6363

64-
Zerocopy provides four macros for safe, zero-cost casting between types:
64+
Zerocopy provides six macros for safe casting between types:
6565

6666
- (`try_`[try_transmute])`transmute` (conditionally) converts a value of
6767
one type to a value of another type of the same size
@@ -72,9 +72,12 @@ Zerocopy provides four macros for safe, zero-cost casting between types:
7272
mutable or immutable reference of one type to an immutable reference of
7373
another type of the same size
7474

75-
These macros perform *compile-time* alignment and size checks, but cannot be
76-
used in generic contexts. For generic conversions, use the methods defined
77-
by the [conversion traits](#conversion-traits).
75+
These macros perform *compile-time* size and alignment checks, meaning that
76+
unconditional casts have zero cost at runtime. Conditional casts do not need
77+
to validate size or alignment runtime, but do need to validate contents.
78+
79+
These macros cannot be used in generic contexts. For generic conversions,
80+
use the methods defined by the [conversion traits](#conversion-traits).
7881

7982
###### Byteorder-Aware Numerics
8083

src/lib.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
//! - [`IntoBytes`] indicates that a type may safely be converted *to* a byte
4343
//! sequence
4444
//!
45-
//! This traits support sized types, slices, and [slice DSTs][slice-dsts].
45+
//! These traits support sized types, slices, and [slice DSTs][slice-dsts].
4646
//!
4747
//! [slice-dsts]: KnownLayout#dynamically-sized-types
4848
//!
@@ -61,7 +61,7 @@
6161
//!
6262
//! ##### Conversion Macros
6363
//!
64-
//! Zerocopy provides four macros for safe, zero-cost casting between types:
64+
//! Zerocopy provides six macros for safe casting between types:
6565
//!
6666
//! - ([`try_`][try_transmute])[`transmute`] (conditionally) converts a value of
6767
//! one type to a value of another type of the same size
@@ -72,9 +72,12 @@
7272
//! mutable or immutable reference of one type to an immutable reference of
7373
//! another type of the same size
7474
//!
75-
//! These macros perform *compile-time* alignment and size checks, but cannot be
76-
//! used in generic contexts. For generic conversions, use the methods defined
77-
//! by the [conversion traits](#conversion-traits).
75+
//! These macros perform *compile-time* size and alignment checks, meaning that
76+
//! unconditional casts have zero cost at runtime. Conditional casts do not need
77+
//! to validate size or alignment runtime, but do need to validate contents.
78+
//!
79+
//! These macros cannot be used in generic contexts. For generic conversions,
80+
//! use the methods defined by the [conversion traits](#conversion-traits).
7881
//!
7982
//! ##### Byteorder-Aware Numerics
8083
//!

0 commit comments

Comments
 (0)