File tree Expand file tree Collapse file tree 2 files changed +49
-1
lines changed
Expand file tree Collapse file tree 2 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " app_units"
3- version = " 0.7.5 "
3+ version = " 0.7.6 "
44authors = [" The Servo Project Developers" ]
55description = " Servo app units type (Au)"
66documentation = " https://docs.rs/app_units/"
Original file line number Diff line number Diff line change @@ -277,6 +277,16 @@ impl Au {
277277 pub fn abs ( self ) -> Self {
278278 Au ( self . 0 . abs ( ) )
279279 }
280+
281+ #[ inline]
282+ pub fn max_assign ( & mut self , other : Self ) {
283+ * self = ( * self ) . max ( other) ;
284+ }
285+
286+ #[ inline]
287+ pub fn min_assign ( & mut self , other : Self ) {
288+ * self = ( * self ) . min ( other) ;
289+ }
280290}
281291
282292#[ test]
@@ -399,6 +409,44 @@ fn convert() {
399409 assert_eq ! ( Au :: from_f64_px( 6.13 ) , Au ( 368 ) ) ;
400410}
401411
412+ #[ test]
413+ fn max_assign ( ) {
414+ let mut au = Au ( 5 ) ;
415+ au. max_assign ( Au ( 10 ) ) ;
416+ assert_eq ! ( au, Au ( 10 ) ) ;
417+
418+ let mut au = Au ( 5 ) ;
419+ au. max_assign ( Au ( -10 ) ) ;
420+ assert_eq ! ( au, Au ( 5 ) ) ;
421+
422+ let mut au = Au ( 100 ) ;
423+ au. max_assign ( MAX_AU ) ;
424+ assert_eq ! ( au, MAX_AU ) ;
425+
426+ let mut au = Au ( -100 ) ;
427+ au. max_assign ( MAX_AU ) ;
428+ assert_eq ! ( au, MAX_AU ) ;
429+ }
430+
431+ #[ test]
432+ fn min_assign ( ) {
433+ let mut au = Au ( 5 ) ;
434+ au. min_assign ( Au ( 10 ) ) ;
435+ assert_eq ! ( au, Au ( 5 ) ) ;
436+
437+ let mut au = Au ( 5 ) ;
438+ au. min_assign ( Au ( -10 ) ) ;
439+ assert_eq ! ( au, Au ( -10 ) ) ;
440+
441+ let mut au = Au ( 100 ) ;
442+ au. min_assign ( MAX_AU ) ;
443+ assert_eq ! ( au, Au ( 100 ) ) ;
444+
445+ let mut au = Au ( -100 ) ;
446+ au. min_assign ( MAX_AU ) ;
447+ assert_eq ! ( au, Au ( -100 ) ) ;
448+ }
449+
402450#[ cfg( feature = "serde_serialization" ) ]
403451#[ test]
404452fn serialize ( ) {
You can’t perform that action at this time.
0 commit comments