completed till 11
This commit is contained in:
@@ -1,6 +1,14 @@
|
||||
// TODO: Define a function named `squared` that raises all `i32`s within a slice to the power of 2.
|
||||
// The slice should be modified in place.
|
||||
|
||||
fn squared(v: &mut [i32]) {
|
||||
for val in v.iter_mut() {
|
||||
*val = val.pow(2);
|
||||
}
|
||||
// let b = v.iter().map(|a| a.pow(2)).collect::<Vec<_>>().as_slice();
|
||||
// v = b;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user