MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / wrapping_offset

Method wrapping_offset

crates/cust/src/memory/pointer.rs:169–180  ·  view source on GitHub ↗

Calculates the offset from a device pointer using wrapping arithmetic. `count` is in units of T; eg. a `count` of 3 represents a pointer offset of `3 * size_of:: ()` bytes. # Safety The resulting pointer does not need to be in bounds, but it is potentially hazardous to dereference (which requires `unsafe`). In particular, the resulting pointer may *not* be used to access a different allocated

(self, count: isize)

Source from the content-addressed store, hash-verified

167 /// }
168 /// ```
169 pub fn wrapping_offset(self, count: isize) -> Self
170 where
171 T: Sized,
172 {
173 let ptr = self
174 .ptr
175 .wrapping_add((count as usize * size_of::<T>()) as u64);
176 Self {
177 ptr,
178 marker: PhantomData,
179 }
180 }
181
182 /// Calculates the offset from a pointer (convenience for `.offset(count as isize)`).
183 ///

Callers 2

wrapping_addMethod · 0.80
wrapping_subMethod · 0.80

Calls 1

wrapping_addMethod · 0.80

Tested by

no test coverage detected