Решение на Code Identifier от Александър Каракушев
Към профила на Александър Каракушев
Резултати
- 0 точки от тестове
- 0 бонус точки
- 0 точки общо
- 0 успешни тест(а)
- 15 неуспешни тест(а)
Код
Лог от изпълнението
Compiling solution v0.1.0 (/tmp/d20190123-22631-clxyk8/solution)
warning: function is never used: `main`
--> src/lib.rs:124:1
|
124 | fn main()
| ^^^^^^^^^
|
= note: #[warn(dead_code)] on by default
Finished dev [unoptimized + debuginfo] target(s) in 4.67s
Running target/debug/deps/solution-2e785d603b538f71
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/solution_test-29808948fb50ed3a
running 15 tests
test solution_test::test_both_static_and_dynamic_strings ... FAILED
test solution_test::test_camelcase_basic ... FAILED
test solution_test::test_cyrillic1 ... FAILED
test solution_test::test_digits1 ... FAILED
test solution_test::test_digits2 ... FAILED
test solution_test::test_digits3 ... FAILED
test solution_test::test_kebabcase_basic ... FAILED
test solution_test::test_multibyte_uppercase ... FAILED
test solution_test::test_normalize_case1 ... FAILED
test solution_test::test_normalize_case2 ... FAILED
test solution_test::test_screaming_snakecase_basic ... FAILED
test solution_test::test_titlecase_basic ... FAILED
test solution_test::test_underscore_basic ... FAILED
test solution_test::test_validity ... FAILED
test solution_test::test_whitespace ... FAILED
failures:
---- solution_test::test_both_static_and_dynamic_strings stdout ----
thread 'solution_test::test_both_static_and_dynamic_strings' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
note: Run with `RUST_BACKTRACE=1` for a backtrace.
---- solution_test::test_camelcase_basic stdout ----
thread 'solution_test::test_camelcase_basic' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_cyrillic1 stdout ----
thread 'solution_test::test_cyrillic1' panicked at 'not yet implemented', src/lib.rs:77:9
---- solution_test::test_digits1 stdout ----
thread 'solution_test::test_digits1' panicked at 'index out of bounds: the len is 12 but the index is 12', libcore/slice/mod.rs:2448:10
---- solution_test::test_digits2 stdout ----
thread 'solution_test::test_digits2' panicked at 'index out of bounds: the len is 12 but the index is 12', libcore/slice/mod.rs:2448:10
---- solution_test::test_digits3 stdout ----
thread 'solution_test::test_digits3' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21
---- solution_test::test_kebabcase_basic stdout ----
thread 'solution_test::test_kebabcase_basic' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_multibyte_uppercase stdout ----
thread 'solution_test::test_multibyte_uppercase' panicked at 'called `Option::unwrap()` on a `None` value', libcore/option.rs:355:21
---- solution_test::test_normalize_case1 stdout ----
thread 'solution_test::test_normalize_case1' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_normalize_case2 stdout ----
thread 'solution_test::test_normalize_case2' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_screaming_snakecase_basic stdout ----
thread 'solution_test::test_screaming_snakecase_basic' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_titlecase_basic stdout ----
thread 'solution_test::test_titlecase_basic' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_underscore_basic stdout ----
thread 'solution_test::test_underscore_basic' panicked at 'index out of bounds: the len is 8 but the index is 8', libcore/slice/mod.rs:2448:10
---- solution_test::test_validity stdout ----
thread 'solution_test::test_validity' panicked at 'assertion failed: CodeIdentifier::new("+_+").is_none()', tests/solution_test.rs:11:5
---- solution_test::test_whitespace stdout ----
thread 'solution_test::test_whitespace' panicked at 'not yet implemented', src/lib.rs:77:9
failures:
solution_test::test_both_static_and_dynamic_strings
solution_test::test_camelcase_basic
solution_test::test_cyrillic1
solution_test::test_digits1
solution_test::test_digits2
solution_test::test_digits3
solution_test::test_kebabcase_basic
solution_test::test_multibyte_uppercase
solution_test::test_normalize_case1
solution_test::test_normalize_case2
solution_test::test_screaming_snakecase_basic
solution_test::test_titlecase_basic
solution_test::test_underscore_basic
solution_test::test_validity
solution_test::test_whitespace
test result: FAILED. 0 passed; 15 failed; 0 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '--test solution_test'

Нямаш нужда да пазиш
Option<String>тук. Ако нямаш валиден идентификатор, просто няма да конструирашCodeIdentifier.В условието описахме, че проверката е дали символа е
is_alphabetic(), и това включва доста повече от латинската азбука. А и щеше да е по-лесно да го имплементираш с викане на този метод, вместо да изброиш азбуката и да викашcontains:).