Решение на упр.03 задача 2 от Станислав Стаматов
Към профила на Станислав Стаматов
Резултати
- 1 точка от тестове
- 0 бонус точки
- 1 точка общо
- 1 успешни тест(а)
- 0 неуспешни тест(а)
Код
Лог от изпълнението
Updating crates.io index
Locking 17 packages to latest compatible versions
Compiling proc-macro2 v1.0.103
Compiling unicode-ident v1.0.22
Compiling quote v1.0.41
Compiling futures-core v0.3.31
Compiling futures-sink v0.3.31
Compiling futures-channel v0.3.31
Compiling pin-project-lite v0.2.16
Compiling memchr v2.7.6
Compiling syn v2.0.108
Compiling pin-utils v0.1.0
Compiling futures-task v0.3.31
Compiling futures-io v0.3.31
Compiling slab v0.4.11
Compiling solution v0.1.0 (/tmp/d20251030-1757769-1o0x5lv/solution)
warning: enum `DriveError` is never used
--> src/lib.rs:1:6
|
1 | enum DriveError {
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: enum `VehicleKind` is never used
--> src/lib.rs:4:6
|
4 | enum VehicleKind {
| ^^^^^^^^^^^
warning: struct `Vehicle` is never constructed
--> src/lib.rs:11:8
|
11 | struct Vehicle {
| ^^^^^^^
warning: associated items `new` and `drive` are never used
--> src/lib.rs:18:12
|
17 | impl Vehicle {
| ------------ associated items in this implementation
18 | pub fn new(kind: VehicleKind, fuel: f64) -> Self {
| ^^^
...
25 | pub fn drive(&mut self, km: f64) -> Result<(), DriveError> {
| ^^^^^
warning: `solution` (lib) generated 4 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: fields `needed` and `have` are never read
--> tests/../src/lib.rs:2:21
|
2 | NotEnoughFuel { needed: f64, have: f64 },
| ------------- ^^^^^^ ^^^^
| |
| fields in this variant
|
= note: `#[warn(dead_code)]` on by default
warning: variants `Truck`, `Motorcycle`, and `Bicycle` are never constructed
--> tests/../src/lib.rs:6:5
|
4 | enum VehicleKind {
| ----------- variants in this enum
5 | Car,
6 | Truck,
| ^^^^^
7 | Motorcycle,
| ^^^^^^^^^^
8 | Bicycle,
| ^^^^^^^
warning: field `distance` is never read
--> tests/../src/lib.rs:14:5
|
11 | struct Vehicle {
| ------- field in this struct
...
14 | distance: f64,
| ^^^^^^^^
warning: `solution` (test "solution_test") generated 3 warnings
Finished `test` profile [unoptimized + debuginfo] target(s) in 8.38s
Running tests/solution_test.rs (target/debug/deps/solution_test-bfd50394249726db)
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

Не ли по-добре да се връща Result<Self, някаква грешка> например за невалидни данни като fuel <0