File tree 1 file changed +18
-1
lines changed
1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,12 @@ pub trait Value {
22
22
23
23
impl < T : string:: ToString + str:: FromStr < Err : fmt:: Debug > + fmt:: Debug > Value for T {
24
24
fn typ ( & self ) -> & str {
25
- std:: any:: type_name :: < T > ( )
25
+ let type_name = std:: any:: type_name :: < T > ( ) ;
26
+ & type_name[ ( type_name
27
+ . rfind ( ':' )
28
+ . map ( |v| v as isize )
29
+ . unwrap_or_else ( || -1 )
30
+ + 1 ) as usize ..]
26
31
}
27
32
28
33
fn set ( & mut self , val : string:: String ) -> Result < ( ) , string:: String > {
@@ -40,3 +45,15 @@ impl<T: string::ToString + str::FromStr<Err: fmt::Debug> + fmt::Debug> Value for
40
45
self . to_string ( )
41
46
}
42
47
}
48
+
49
+ #[ cfg( test) ]
50
+ mod test {
51
+ use super :: * ;
52
+
53
+ #[ test]
54
+ fn strip_prefix_from_type_name ( ) {
55
+ let val: Box < dyn Value > = Box :: new ( "" . to_string ( ) ) ;
56
+ let type_name = val. typ ( ) ;
57
+ assert_eq ! ( type_name, "String" )
58
+ }
59
+ }
You can’t perform that action at this time.
0 commit comments