File tree Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Expand file tree Collapse file tree 4 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -747,6 +747,7 @@ impl<T> Vec<T> {
747
747
/// Basic usage:
748
748
///
749
749
/// ```
750
+ /// #![feature(vec_peek_mut)]
750
751
/// let mut vec = Vec::new();
751
752
/// assert!(vec.peek_mut().is_none());
752
753
///
Original file line number Diff line number Diff line change 42
42
#![ feature( trusted_random_access) ]
43
43
#![ feature( try_reserve_kind) ]
44
44
#![ feature( try_trait_v2) ]
45
- #![ feature( vec_peek_mut) ]
46
45
// tidy-alphabetical-end
47
46
//
48
47
// Language features:
Original file line number Diff line number Diff line change 40
40
#![ feature( vec_deque_truncate_front) ]
41
41
#![ feature( unique_rc_arc) ]
42
42
#![ feature( macro_metavar_expr_concat) ]
43
+ #![ feature( vec_peek_mut) ]
43
44
#![ allow( internal_features) ]
44
45
#![ deny( fuzzy_provenance_casts) ]
45
46
#![ deny( unsafe_op_in_unsafe_fn) ]
Original file line number Diff line number Diff line change @@ -2704,9 +2704,13 @@ fn test_peek_mut() {
2704
2704
assert ! ( vec. peek_mut( ) . is_none( ) ) ;
2705
2705
vec. push ( 1 ) ;
2706
2706
vec. push ( 2 ) ;
2707
- assert_eq ! ( vec. peek_mut( ) , Some ( 2 ) ) ;
2708
- * vec. peek_mut ( ) = 0 ;
2709
- assert_eq ! ( vec. peek_mut( ) , Some ( 0 ) ) ;
2707
+ if let Some ( mut p) = vec. peek_mut ( ) {
2708
+ assert_eq ! ( * p, 2 ) ;
2709
+ * p = 0 ;
2710
+ assert_eq ! ( * p, 0 ) ;
2711
+ } else {
2712
+ unreachable ! ( )
2713
+ }
2710
2714
}
2711
2715
2712
2716
/// This assortment of tests, in combination with miri, verifies we handle UB on fishy arguments
You can’t perform that action at this time.
0 commit comments