We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 38ee2e8 commit 8f9a3adCopy full SHA for 8f9a3ad
tests/ui/early-ret-binop-add.rs
tests/ui/expr/early-return-in-binop.rs
@@ -0,0 +1,19 @@
1
+//! Test early return within binary operation expressions
2
+
3
+//@ run-pass
4
5
+#![allow(dead_code)]
6
+#![allow(unreachable_code)]
7
8
+use std::ops::Add;
9
10
+/// Function that performs addition with an early return in the right operand
11
+fn add_with_early_return<T: Add<Output = T> + Copy>(n: T) -> T {
12
+ n + { return n }
13
+}
14
15
+pub fn main() {
16
+ // Test with different numeric types to ensure generic behavior works
17
+ let _result1 = add_with_early_return(42i32);
18
+ let _result2 = add_with_early_return(3.14f64);
19
0 commit comments