File tree 2 files changed +19
-0
lines changed
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change
1
+ Stub doesn't compile because the From trait is not implemented for the every type in the test suite.
2
+ This exercise is an introduction to the From trait and fully implementing this trait for the test suite reduces learning.
Original file line number Diff line number Diff line change
1
+ pub struct Luhn ;
1
2
3
+ impl Luhn {
4
+ pub fn is_valid ( & self ) -> bool {
5
+ unimplemented ! ( "Determine if the current Luhn struct contains a valid credit card number." ) ;
6
+ }
7
+ }
8
+
9
+ /// Here is the example of how the From trait could be implemented
10
+ /// for the &str type. Naturally, you can implement this trait
11
+ /// by hand for the every other type presented in the test suite,
12
+ /// but your solution will fail if a new type is presented.
13
+ /// Perhaps there exists a better solution for this problem?
14
+ impl < ' a > From < & ' a str > for Luhn {
15
+ fn from ( input : & ' a str ) -> Self {
16
+ unimplemented ! ( "From the given input '{}' create a new Luhn struct." , input) ;
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments