Skip to content

Commit 8f9a3ad

Browse files
committed
moved renamed docs formatted | early-ret-binop-add.rs
1 parent 38ee2e8 commit 8f9a3ad

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

tests/ui/early-ret-binop-add.rs

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)