Решение на упр.01 задача 3 от Борис Великов
Резултати
- 0 точки от тестове
- 0 бонус точки
- 0 точки общо
- 0 успешни тест(а)
- 1 неуспешни тест(а)
Код
fn check_password(pass: &str) -> bool {
let bytes :&[u8] = pass.as_bytes();
let last_i: usize = bytes.len() - 1;
if bytes.len()<8 ||
bytes[0]<b'A' || bytes[0]>b'Z'||
bytes[last_i] < b'0' || bytes[last_i] > b'9'{
return false;
}
true
}
Лог от изпълнението
Updating crates.io index
Locking 17 packages to latest compatible versions
Compiling proc-macro2 v1.0.101
Compiling unicode-ident v1.0.19
Compiling quote v1.0.41
Compiling futures-core v0.3.31
Compiling futures-sink v0.3.31
Compiling futures-channel v0.3.31
Compiling futures-task v0.3.31
Compiling memchr v2.7.6
Compiling syn v2.0.106
Compiling futures-io v0.3.31
Compiling slab v0.4.11
Compiling pin-utils v0.1.0
Compiling pin-project-lite v0.2.16
Compiling solution v0.1.0 (/tmp/d20251016-574132-1bmv2lb/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: `solution` (lib) generated 1 warning
Compiling futures-macro v0.3.31
Compiling futures-util v0.3.31
Compiling futures-executor v0.3.31
Compiling futures v0.3.31
Finished `test` profile [unoptimized + debuginfo] target(s) in 8.21s
Running tests/solution_test.rs (target/debug/deps/solution_test-80bf62783e3de781)
running 1 test
test solution_test::test_basic ... FAILED
failures:
---- solution_test::test_basic stdout ----
thread 'solution_test::test_basic' panicked at tests/../src/lib.rs:3:25:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
failures:
solution_test::test_basic
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
error: test failed, to rerun pass `--test solution_test`
