Skip to content

Commit 6f10625

Browse files
committed
update unsafe trait docs to include a needed guarantee
and refer to one doc comment instead of duplicating similar ones
1 parent 098c63c commit 6f10625

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/sdl2/render.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,8 @@ impl<T: RenderTarget> Canvas<T> {
19711971
///
19721972
/// The implementation of `as_vertex_position` must
19731973
/// - be pure (have no side effects) and
1974-
/// - return a reference to an [`FPoint`] that is borrowed from `self`.
1974+
/// - return a reference to an [`FPoint`] that is borrowed from the same allocated object as `self`
1975+
/// and has an offset from `self` that is constant (does not change between calls).
19751976
pub unsafe trait AsVertexPosition {
19761977
fn as_vertex_position(&self) -> &FPoint;
19771978
}
@@ -1987,9 +1988,8 @@ unsafe impl AsVertexPosition for FPoint {
19871988
///
19881989
/// # Safety
19891990
///
1990-
/// The implementation of `as_vertex_color` must
1991-
/// - be pure (have no side effects) and
1992-
/// - return a reference to a [`Color`][pixels::Color] that is borrowed from `self`.
1991+
/// See [`AsVertexPosition`], but read `as_vertex_position` as `as_vertex_color` and `FPoint` as
1992+
/// `Color`.
19931993
pub unsafe trait AsVertexColor {
19941994
fn as_vertex_color(&self) -> &pixels::Color;
19951995
}
@@ -2004,9 +2004,7 @@ unsafe impl AsVertexColor for pixels::Color {
20042004
///
20052005
/// # Safety
20062006
///
2007-
/// The implementation of `as_vertex_tex_coord` must
2008-
/// - be pure (have no side effects) and
2009-
/// - return a reference to an [`FPoint`] that is borrowed from `self`.
2007+
/// See [`AsVertexPosition`], but read `as_vertex_position` as `as_vertex_tex_coord`.
20102008
pub unsafe trait AsVertexTexCoord {
20112009
fn as_vertex_tex_coord(&self) -> &FPoint;
20122010
}

0 commit comments

Comments
 (0)