100 exercises to learn Rust
This commit is contained in:
4
exercises/02_basic_calculator/10_as_casting/Cargo.toml
Normal file
4
exercises/02_basic_calculator/10_as_casting/Cargo.toml
Normal file
@@ -0,0 +1,4 @@
|
||||
[package]
|
||||
name = "as_cast"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
22
exercises/02_basic_calculator/10_as_casting/src/lib.rs
Normal file
22
exercises/02_basic_calculator/10_as_casting/src/lib.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
// TODO: based on what you learned in this section, replace `todo!()` with
|
||||
// the correct value after the conversion.
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
#[test]
|
||||
fn u16_to_u32() {
|
||||
assert_eq!(47u16 as u32, todo!());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[allow(overflowing_literals)]
|
||||
fn u8_to_i8() {
|
||||
assert_eq!(255 as i8, todo!());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bool_to_u8() {
|
||||
assert_eq!(true as u8, todo!());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user