File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change 4343{
4444 type Item = T ;
4545
46+ #[ inline]
4647 fn next ( & mut self ) -> Option < T > {
4748 self . it . next ( ) . copied ( )
4849 }
Original file line number Diff line number Diff line change @@ -1794,6 +1794,7 @@ impl<T> Option<&T> {
17941794 /// let copied = opt_x.copied();
17951795 /// assert_eq!(copied, Some(12));
17961796 /// ```
1797+ #[ inline]
17971798 #[ must_use = "`self` will be dropped if the result is not used" ]
17981799 #[ stable( feature = "copied" , since = "1.35.0" ) ]
17991800 #[ rustc_const_unstable( feature = "const_option" , issue = "67441" ) ]
Original file line number Diff line number Diff line change 1+ // compile-flags: -C opt-level=3
2+
3+ #![ crate_type = "lib" ]
4+
5+ extern crate core;
6+ use core:: { iter:: Copied , slice:: Iter } ;
7+
8+ // Make sure that the use of unwrap_unchecked is optimized accordingly.
9+ // i.e., there are no branch jumps.
10+ pub unsafe fn unwrap_unchecked_optimized ( x : & mut Copied < Iter < ' _ , u32 > > ) -> u32 {
11+ // CHECK-NOT: br
12+ x. next ( ) . unwrap_unchecked ( )
13+ }
You can’t perform that action at this time.
0 commit comments