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> {
747747 /// Basic usage:
748748 ///
749749 /// ```
750+ /// #![feature(vec_peek_mut)]
750751 /// let mut vec = Vec::new();
751752 /// assert!(vec.peek_mut().is_none());
752753 ///
Original file line number Diff line number Diff line change 4242#![ feature( trusted_random_access) ]
4343#![ feature( try_reserve_kind) ]
4444#![ feature( try_trait_v2) ]
45- #![ feature( vec_peek_mut) ]
4645// tidy-alphabetical-end
4746//
4847// Language features:
Original file line number Diff line number Diff line change 4040#![ feature( vec_deque_truncate_front) ]
4141#![ feature( unique_rc_arc) ]
4242#![ feature( macro_metavar_expr_concat) ]
43+ #![ feature( vec_peek_mut) ]
4344#![ allow( internal_features) ]
4445#![ deny( fuzzy_provenance_casts) ]
4546#![ deny( unsafe_op_in_unsafe_fn) ]
Original file line number Diff line number Diff line change @@ -2704,9 +2704,13 @@ fn test_peek_mut() {
27042704 assert ! ( vec. peek_mut( ) . is_none( ) ) ;
27052705 vec. push ( 1 ) ;
27062706 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+ }
27102714}
27112715
27122716/// 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