@@ -231,10 +231,10 @@ impl Rect {
231
231
///
232
232
/// ```
233
233
/// use sdl2::rect::Rect;
234
- /// assert_eq!(Rect::new(0, 0 , 10, 10).left_shifted(5), Rect::new(-5, 0 , 10, 10));
234
+ /// assert_eq!(Rect::new(5, 5 , 10, 10).left_shifted(5), Rect::new(0, 5 , 10, 10));
235
235
/// ```
236
236
pub fn left_shifted ( mut self , offset : i32 ) -> Rect {
237
- self . offset ( -offset, self . y ( ) ) ;
237
+ self . offset ( -offset, 0 ) ;
238
238
self
239
239
}
240
240
@@ -244,10 +244,10 @@ impl Rect {
244
244
///
245
245
/// ```
246
246
/// use sdl2::rect::Rect;
247
- /// assert_eq!(Rect::new(0, 0 , 10, 10).right_shifted(5), Rect::new(5, 0 , 10, 10));
247
+ /// assert_eq!(Rect::new(5, 5 , 10, 10).right_shifted(5), Rect::new(10, 5 , 10, 10));
248
248
/// ```
249
249
pub fn right_shifted ( mut self , offset : i32 ) -> Rect {
250
- self . offset ( offset, self . y ( ) ) ;
250
+ self . offset ( offset, 0 ) ;
251
251
self
252
252
}
253
253
@@ -257,10 +257,10 @@ impl Rect {
257
257
///
258
258
/// ```
259
259
/// use sdl2::rect::Rect;
260
- /// assert_eq!(Rect::new(0, 0 , 10, 10).top_shifted(5), Rect::new(0, -5 , 10, 10));
260
+ /// assert_eq!(Rect::new(5, 5 , 10, 10).top_shifted(5), Rect::new(5, 0 , 10, 10));
261
261
/// ```
262
262
pub fn top_shifted ( mut self , offset : i32 ) -> Rect {
263
- self . offset ( self . x ( ) , -offset) ;
263
+ self . offset ( 0 , -offset) ;
264
264
self
265
265
}
266
266
@@ -270,10 +270,10 @@ impl Rect {
270
270
///
271
271
/// ```
272
272
/// use sdl2::rect::Rect;
273
- /// assert_eq!(Rect::new(0, 0 , 10, 10).bottom_shifted(5), Rect::new(0, 5 , 10, 10));
273
+ /// assert_eq!(Rect::new(5, 5 , 10, 10).bottom_shifted(5), Rect::new(5, 10 , 10, 10));
274
274
/// ```
275
275
pub fn bottom_shifted ( mut self , offset : i32 ) -> Rect {
276
- self . offset ( self . x ( ) , offset) ;
276
+ self . offset ( 0 , offset) ;
277
277
self
278
278
}
279
279
@@ -1094,12 +1094,12 @@ mod test {
1094
1094
#[ test]
1095
1095
fn shifted ( ) {
1096
1096
// Groups all functions into a single assertion
1097
- let rect = Rect :: new ( 0 , 0 , 10 , 10 )
1097
+ let rect = Rect :: new ( 5 , 5 , 10 , 10 )
1098
1098
. left_shifted ( 5 )
1099
1099
. right_shifted ( 5 )
1100
1100
. top_shifted ( 5 )
1101
1101
. bottom_shifted ( 5 ) ;
1102
- assert_eq ! ( rect, Rect :: new( 0 , 0 , 10 , 10 ) ) ;
1102
+ assert_eq ! ( rect, Rect :: new( 5 , 5 , 10 , 10 ) ) ;
1103
1103
}
1104
1104
1105
1105
#[ test]
0 commit comments