-
-
Save hyunsik/c873d59a438e3c910c65 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn filter<T>(res: &mut [usize], lhs: &[T], rhs: &[T]) | |
where T : Copy + PartialOrd { | |
let mut matched: usize = 0; | |
for x in 0..lhs.len() { | |
res[matched] = x; | |
matched = matched + if lhs[x] > rhs[x] { 1 } else { 0 }; | |
} | |
} | |
fn main() { | |
let mut res: [usize;4] = [0,0,0,0]; | |
let lhs: [i32;4] = [1,2,3,4]; | |
let rhs: [i32;4] = [5,6,7,8]; | |
filter(&mut res, &lhs, &rhs); | |
for x in 0..res.len() { | |
println!("{}", res[x]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment