1
0
mirror of https://github.com/rust-lang/rustlings.git synced 2025-07-09 01:05:50 +02:00
Files
.github
dev
exercises
00_intro
01_variables
02_functions
03_if
04_primitive_types
05_vecs
06_move_semantics
07_structs
08_enums
09_strings
10_modules
11_hashmaps
12_options
13_error_handling
14_generics
15_traits
16_lifetimes
17_tests
README.md
tests1.rs
tests2.rs
tests3.rs
18_iterators
19_smart_pointers
20_threads
21_macros
22_clippy
23_conversions
quizzes
README.md
rustlings-macros
solutions
src
tests
.editorconfig
.gitignore
.markdownlint.yml
.typos.toml
CHANGELOG.md
CONTRIBUTING.md
Cargo.lock
Cargo.toml
LICENSE
README.md
THIRD_PARTY_EXERCISES.md
build.rs
clippy.toml
oranda.json
release-hook.sh
rustlings/exercises/17_tests/tests2.rs

24 lines
449 B
Rust
Raw Normal View History

2024-06-27 16:40:26 +02:00
// Calculates the power of 2 using a bit shift.
// `1 << n` is equivalent to "2 to the power of n".
fn power_of_2(n: u8) -> u64 {
1 << n
}
2015-09-20 18:31:41 -04:00
fn main() {
// You can optionally experiment here.
}
2015-09-20 18:31:41 -04:00
#[cfg(test)]
mod tests {
2024-06-27 16:40:26 +02:00
use super::*;
2015-09-20 18:31:41 -04:00
#[test]
fn you_can_assert_eq() {
2024-06-27 16:40:26 +02:00
// TODO: Test the function `power_of_2` with some values.
assert_eq!();
assert_eq!();
assert_eq!();
2015-09-20 18:31:41 -04:00
assert_eq!();
}
}