fix(using_as): Add test so that proper type is returned. (#512)
This commit is contained in:
parent
ee7cdc66b3
commit
3286c5ec19
@ -3,6 +3,7 @@
|
|||||||
// It also helps with renaming imports.
|
// It also helps with renaming imports.
|
||||||
//
|
//
|
||||||
// The goal is to make sure that the division does not fail to compile
|
// The goal is to make sure that the division does not fail to compile
|
||||||
|
// and returns the proper type.
|
||||||
|
|
||||||
// I AM NOT DONE
|
// I AM NOT DONE
|
||||||
|
|
||||||
@ -15,3 +16,13 @@ fn main() {
|
|||||||
let values = [3.5, 0.3, 13.0, 11.7];
|
let values = [3.5, 0.3, 13.0, 11.7];
|
||||||
println!("{}", average(&values));
|
println!("{}", average(&values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn returns_proper_type_and_value() {
|
||||||
|
assert_eq!(average(&[3.5, 0.3, 13.0, 11.7]), 7.125);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -787,7 +787,7 @@ what you've learned :)"""
|
|||||||
[[exercises]]
|
[[exercises]]
|
||||||
name = "using_as"
|
name = "using_as"
|
||||||
path = "exercises/conversions/using_as.rs"
|
path = "exercises/conversions/using_as.rs"
|
||||||
mode = "compile"
|
mode = "test"
|
||||||
hint = """
|
hint = """
|
||||||
Use the `as` operator to cast one of the operands in the last line of the
|
Use the `as` operator to cast one of the operands in the last line of the
|
||||||
`average` function into the expected return type."""
|
`average` function into the expected return type."""
|
||||||
|
Loading…
Reference in New Issue
Block a user