Решение на упр.01 задача 3 от Виктор Карталов
Към профила на Виктор Карталов
Резултати
- 1 точка от тестове
- 0 бонус точки
- 1 точка общо
- 1 успешни тест(а)
- 0 неуспешни тест(а)
Код
fn check_password(pass: &str) -> bool {
let passBytes = pass.as_bytes();
if passBytes.len() < 8 {
return false;
}
else if passBytes[0] < 'A' as u8
|| passBytes[0] > 'Z' as u8 {
return false;
}
else if passBytes[passBytes.len() - 1] < '0' as u8
|| passBytes[passBytes.len() - 1] > '9' as u8 {
return false;
}
true
}
Лог от изпълнението
Updating crates.io index
Locking 17 packages to latest compatible versions
Compiling proc-macro2 v1.0.101
Compiling quote v1.0.41
Compiling unicode-ident v1.0.19
Compiling futures-core v0.3.31
Compiling futures-sink v0.3.31
Compiling futures-channel v0.3.31
Compiling futures-io v0.3.31
Compiling futures-task v0.3.31
Compiling slab v0.4.11
Compiling syn v2.0.106
Compiling memchr v2.7.6
Compiling pin-utils v0.1.0
Compiling pin-project-lite v0.2.16
Compiling solution v0.1.0 (/tmp/d20251016-574132-hf174s/solution)
warning: function `check_password` is never used
--> src/lib.rs:1:4
|
1 | fn check_password(pass: &str) -> bool {
| ^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: variable `passBytes` should have a snake case name
--> src/lib.rs:2:9
|
2 | let passBytes = pass.as_bytes();
| ^^^^^^^^^ help: convert the identifier to snake case: `pass_bytes`
|
= note: `#[warn(non_snake_case)]` on by default
warning: `solution` (lib) generated 2 warnings
Compiling futures-macro v0.3.31
Compiling futures-util v0.3.31
Compiling futures-executor v0.3.31
Compiling futures v0.3.31
warning: variable `passBytes` should have a snake case name
--> tests/../src/lib.rs:2:9
|
2 | let passBytes = pass.as_bytes();
| ^^^^^^^^^ help: convert the identifier to snake case: `pass_bytes`
|
= note: `#[warn(non_snake_case)]` on by default
warning: `solution` (test "solution_test") generated 1 warning
Finished `test` profile [unoptimized + debuginfo] target(s) in 8.20s
Running tests/solution_test.rs (target/debug/deps/solution_test-80bf62783e3de781)
running 1 test
test solution_test::test_basic ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
