51
51
//! }
52
52
//! # }
53
53
//! ```
54
- //!
55
- //! If you want to add attribute to a specific generated struct(such as
54
+ //!
55
+ //! If you want to add attribute to a specific generated struct(such as
56
56
//! `#[cfg_attr(test, derive(PartialEq))]` on `CheeseVec`), you can add an
57
- //! attribute `#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]` to the
57
+ //! attribute `#[soa_attr(Vec, cfg_attr(test, derive(PartialEq)))]` to the
58
58
//! struct declaration.
59
- //!
59
+ //!
60
60
//! ```
61
61
//! # #[macro_use] extern crate soa_derive;
62
62
//! # fn main() {
70
70
//! }
71
71
//! # }
72
72
//! ```
73
- //!
74
- //! Mappings for first argument of ``soa_attr`` to the generated struct for ``Cheese``:
73
+ //!
74
+ //! Mappings for first argument of ``soa_attr`` to the generated struct for ``Cheese``:
75
75
//! * `Vec` => `CheeseVec`
76
76
//! * `Slice` => `CheeseSlice`
77
77
//! * `SliceMut` => `CheeseSliceMut`
188
188
// macro_rules macro.
189
189
pub use soa_derive_internal:: StructOfArray ;
190
190
191
- /// Any struct derived by StructOfArray will auto impl this trait
192
- /// You can use `<Cheese as StructOfArray>::Type`
193
- /// instead of explicit named type `CheeseVec`; This will helpful in generics programing
194
- /// that generate struct can be expressed as `<T as StructOfArray>::Type`
191
+ /// Any struct derived by StructOfArray will auto impl this trait You can use
192
+ /// `<Cheese as StructOfArray>::Type` instead of explicit named type
193
+ /// `CheeseVec`; This will helpful in generics programing that generate struct
194
+ /// can be expressed as `<T as StructOfArray>::Type`
195
195
pub trait StructOfArray {
196
196
type Type ;
197
197
}
@@ -221,11 +221,17 @@ pub trait SoAIndex<T>: private_soa_indexes::Sealed {
221
221
/// The output for the non-mutable functions
222
222
type RefOutput ;
223
223
224
- /// Returns the reference output in this location if in bounds, `None` otherwise.
224
+ /// Returns the reference output in this location if in bounds, `None`
225
+ /// otherwise.
225
226
fn get ( self , soa : T ) -> Option < Self :: RefOutput > ;
226
- /// Returns the reference output in this location without performing any bounds check.
227
+ /// Returns the reference output in this location without performing any
228
+ /// bounds check.
229
+ ///
230
+ /// # Safety
231
+ /// The index must be in bounds.
227
232
unsafe fn get_unchecked ( self , soa : T ) -> Self :: RefOutput ;
228
- /// Returns the reference output in this location. Panics if it is not in bounds.
233
+ /// Returns the reference output in this location. Panics if it is not in
234
+ /// bounds.
229
235
fn index ( self , soa : T ) -> Self :: RefOutput ;
230
236
}
231
237
@@ -235,11 +241,17 @@ pub trait SoAIndexMut<T>: private_soa_indexes::Sealed {
235
241
/// The output for the mutable functions
236
242
type MutOutput ;
237
243
238
- /// Returns the mutable reference output in this location if in bounds, `None` otherwise.
244
+ /// Returns the mutable reference output in this location if in bounds,
245
+ /// `None` otherwise.
239
246
fn get_mut ( self , soa : T ) -> Option < Self :: MutOutput > ;
240
- /// Returns the mutable reference output in this location without performing any bounds check.
247
+ /// Returns the mutable reference output in this location without performing
248
+ /// any bounds check.
249
+ ///
250
+ /// # Safety
251
+ /// The index must be in bounds.
241
252
unsafe fn get_unchecked_mut ( self , soa : T ) -> Self :: MutOutput ;
242
- /// Returns the mutable reference output in this location. Panics if it is not in bounds.
253
+ /// Returns the mutable reference output in this location. Panics if it is
254
+ /// not in bounds.
243
255
fn index_mut ( self , soa : T ) -> Self :: MutOutput ;
244
256
}
245
257
0 commit comments