From ee1c0be2dd6b98dacce368e3ec556a43bfa6ed4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Mon, 12 Apr 2021 11:27:21 +0200 Subject: [PATCH] Add a note about the PhantomData in Matrix. --- src/base/matrix.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/base/matrix.rs b/src/base/matrix.rs index cbd3bdd9..bfa2bb35 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -176,6 +176,16 @@ pub struct Matrix { /// starts at 0 as you would expect. pub data: S, + // NOTE: the fact that this field is private is important because + // this prevents the user from constructing a matrix with + // dimensions R, C that don't match the dimension of the + // storage S. Instead they have to use the unsafe function + // from_data_statically_unchecked. + // Note that it would probably make sense to just have + // the type `Matrix`, and have `T, R, C` be associated-types + // of the `Storage` trait. However, because we don't have + // specialization, this is not bossible because these `T, R, C` + // allows us to desambiguate a lot of configurations. _phantoms: PhantomData<(T, R, C)>, }