@@ -15,7 +15,7 @@ impl<'v> Value<'v> {
1515 ///
1616 /// This method is cheap for primitive types, but may call arbitrary
1717 /// serialization implementations for complex ones.
18- pub fn as_usize ( & self ) -> Option < usize > {
18+ pub fn to_usize ( & self ) -> Option < usize > {
1919 self . inner
2020 . cast ( )
2121 . into_primitive ( )
@@ -27,7 +27,7 @@ impl<'v> Value<'v> {
2727 ///
2828 /// This method is cheap for primitive types, but may call arbitrary
2929 /// serialization implementations for complex ones.
30- pub fn as_u8 ( & self ) -> Option < u8 > {
30+ pub fn to_u8 ( & self ) -> Option < u8 > {
3131 self . inner
3232 . cast ( )
3333 . into_primitive ( )
@@ -39,7 +39,7 @@ impl<'v> Value<'v> {
3939 ///
4040 /// This method is cheap for primitive types, but may call arbitrary
4141 /// serialization implementations for complex ones.
42- pub fn as_u16 ( & self ) -> Option < u16 > {
42+ pub fn to_u16 ( & self ) -> Option < u16 > {
4343 self . inner
4444 . cast ( )
4545 . into_primitive ( )
@@ -51,7 +51,7 @@ impl<'v> Value<'v> {
5151 ///
5252 /// This method is cheap for primitive types, but may call arbitrary
5353 /// serialization implementations for complex ones.
54- pub fn as_u32 ( & self ) -> Option < u32 > {
54+ pub fn to_u32 ( & self ) -> Option < u32 > {
5555 self . inner
5656 . cast ( )
5757 . into_primitive ( )
@@ -63,15 +63,15 @@ impl<'v> Value<'v> {
6363 ///
6464 /// This method is cheap for primitive types, but may call arbitrary
6565 /// serialization implementations for complex ones.
66- pub fn as_u64 ( & self ) -> Option < u64 > {
66+ pub fn to_u64 ( & self ) -> Option < u64 > {
6767 self . inner . cast ( ) . into_primitive ( ) . into_u64 ( )
6868 }
6969
7070 /// Try get a `isize` from this value.
7171 ///
7272 /// This method is cheap for primitive types, but may call arbitrary
7373 /// serialization implementations for complex ones.
74- pub fn as_isize ( & self ) -> Option < isize > {
74+ pub fn to_isize ( & self ) -> Option < isize > {
7575 self . inner
7676 . cast ( )
7777 . into_primitive ( )
@@ -83,7 +83,7 @@ impl<'v> Value<'v> {
8383 ///
8484 /// This method is cheap for primitive types, but may call arbitrary
8585 /// serialization implementations for complex ones.
86- pub fn as_i8 ( & self ) -> Option < i8 > {
86+ pub fn to_i8 ( & self ) -> Option < i8 > {
8787 self . inner
8888 . cast ( )
8989 . into_primitive ( )
@@ -95,7 +95,7 @@ impl<'v> Value<'v> {
9595 ///
9696 /// This method is cheap for primitive types, but may call arbitrary
9797 /// serialization implementations for complex ones.
98- pub fn as_i16 ( & self ) -> Option < i16 > {
98+ pub fn to_i16 ( & self ) -> Option < i16 > {
9999 self . inner
100100 . cast ( )
101101 . into_primitive ( )
@@ -107,7 +107,7 @@ impl<'v> Value<'v> {
107107 ///
108108 /// This method is cheap for primitive types, but may call arbitrary
109109 /// serialization implementations for complex ones.
110- pub fn as_i32 ( & self ) -> Option < i32 > {
110+ pub fn to_i32 ( & self ) -> Option < i32 > {
111111 self . inner
112112 . cast ( )
113113 . into_primitive ( )
@@ -119,15 +119,15 @@ impl<'v> Value<'v> {
119119 ///
120120 /// This method is cheap for primitive types, but may call arbitrary
121121 /// serialization implementations for complex ones.
122- pub fn as_i64 ( & self ) -> Option < i64 > {
122+ pub fn to_i64 ( & self ) -> Option < i64 > {
123123 self . inner . cast ( ) . into_primitive ( ) . into_i64 ( )
124124 }
125125
126126 /// Try get a `f32` from this value.
127127 ///
128128 /// This method is cheap for primitive types, but may call arbitrary
129129 /// serialization implementations for complex ones.
130- pub fn as_f32 ( & self ) -> Option < f32 > {
130+ pub fn to_f32 ( & self ) -> Option < f32 > {
131131 self . inner
132132 . cast ( )
133133 . into_primitive ( )
@@ -139,31 +139,31 @@ impl<'v> Value<'v> {
139139 ///
140140 /// This method is cheap for primitive types, but may call arbitrary
141141 /// serialization implementations for complex ones.
142- pub fn as_f64 ( & self ) -> Option < f64 > {
142+ pub fn to_f64 ( & self ) -> Option < f64 > {
143143 self . inner . cast ( ) . into_primitive ( ) . into_f64 ( )
144144 }
145145
146146 /// Try get a `bool` from this value.
147147 ///
148148 /// This method is cheap for primitive types, but may call arbitrary
149149 /// serialization implementations for complex ones.
150- pub fn as_bool ( & self ) -> Option < bool > {
150+ pub fn to_bool ( & self ) -> Option < bool > {
151151 self . inner . cast ( ) . into_primitive ( ) . into_bool ( )
152152 }
153153
154154 /// Try get a `char` from this value.
155155 ///
156156 /// This method is cheap for primitive types, but may call arbitrary
157157 /// serialization implementations for complex ones.
158- pub fn as_char ( & self ) -> Option < char > {
158+ pub fn to_char ( & self ) -> Option < char > {
159159 self . inner . cast ( ) . into_primitive ( ) . into_char ( )
160160 }
161161
162162 /// Try get a `str` from this value.
163163 ///
164164 /// This method is cheap for primitive types. It won't allocate an owned
165165 /// `String` if the value is a complex type.
166- pub fn as_borrowed_str ( & self ) -> Option < & str > {
166+ pub fn to_borrowed_str ( & self ) -> Option < & str > {
167167 self . inner . cast ( ) . into_primitive ( ) . into_borrowed_str ( )
168168 }
169169}
@@ -384,7 +384,7 @@ mod std_support {
384384 /// This method is cheap for primitive types, but may call arbitrary
385385 /// serialization implementations for complex ones. If the serialization
386386 /// implementation produces a short lived string it will be allocated.
387- pub fn as_str ( & self ) -> Option < Cow < str > > {
387+ pub fn to_str ( & self ) -> Option < Cow < str > > {
388388 self . inner . cast ( ) . into_str ( )
389389 }
390390 }
@@ -410,19 +410,19 @@ mod std_support {
410410 "a string"
411411 . to_owned( )
412412 . to_value( )
413- . as_borrowed_str ( )
413+ . to_borrowed_str ( )
414414 . expect( "invalid value" )
415415 ) ;
416416 assert_eq ! (
417417 "a string" ,
418- & * "a string" . to_value( ) . as_str ( ) . expect( "invalid value" )
418+ & * "a string" . to_value( ) . to_str ( ) . expect( "invalid value" )
419419 ) ;
420420 assert_eq ! (
421421 "a string" ,
422422 & * "a string"
423423 . to_owned( )
424424 . to_value( )
425- . as_str ( )
425+ . to_str ( )
426426 . expect( "invalid value" )
427427 ) ;
428428 }
@@ -439,37 +439,37 @@ mod tests {
439439 "a string" ,
440440 "a string"
441441 . to_value( )
442- . as_borrowed_str ( )
442+ . to_borrowed_str ( )
443443 . expect( "invalid value" )
444444 ) ;
445445 assert_eq ! (
446446 "a string" ,
447447 Some ( "a string" )
448448 . to_value( )
449- . as_borrowed_str ( )
449+ . to_borrowed_str ( )
450450 . expect( "invalid value" )
451451 ) ;
452452
453- assert_eq ! ( 1u8 , 1u64 . to_value( ) . as_u8 ( ) . expect( "invalid value" ) ) ;
454- assert_eq ! ( 1u16 , 1u64 . to_value( ) . as_u16 ( ) . expect( "invalid value" ) ) ;
455- assert_eq ! ( 1u32 , 1u64 . to_value( ) . as_u32 ( ) . expect( "invalid value" ) ) ;
456- assert_eq ! ( 1u64 , 1u64 . to_value( ) . as_u64 ( ) . expect( "invalid value" ) ) ;
457- assert_eq ! ( 1usize , 1u64 . to_value( ) . as_usize ( ) . expect( "invalid value" ) ) ;
453+ assert_eq ! ( 1u8 , 1u64 . to_value( ) . to_u8 ( ) . expect( "invalid value" ) ) ;
454+ assert_eq ! ( 1u16 , 1u64 . to_value( ) . to_u16 ( ) . expect( "invalid value" ) ) ;
455+ assert_eq ! ( 1u32 , 1u64 . to_value( ) . to_u32 ( ) . expect( "invalid value" ) ) ;
456+ assert_eq ! ( 1u64 , 1u64 . to_value( ) . to_u64 ( ) . expect( "invalid value" ) ) ;
457+ assert_eq ! ( 1usize , 1u64 . to_value( ) . to_usize ( ) . expect( "invalid value" ) ) ;
458458
459- assert_eq ! ( -1i8 , -1i64 . to_value( ) . as_i8 ( ) . expect( "invalid value" ) ) ;
460- assert_eq ! ( -1i16 , -1i64 . to_value( ) . as_i16 ( ) . expect( "invalid value" ) ) ;
461- assert_eq ! ( -1i32 , -1i64 . to_value( ) . as_i32 ( ) . expect( "invalid value" ) ) ;
462- assert_eq ! ( -1i64 , -1i64 . to_value( ) . as_i64 ( ) . expect( "invalid value" ) ) ;
463- assert_eq ! ( -1isize , -1i64 . to_value( ) . as_isize ( ) . expect( "invalid value" ) ) ;
459+ assert_eq ! ( -1i8 , -1i64 . to_value( ) . to_i8 ( ) . expect( "invalid value" ) ) ;
460+ assert_eq ! ( -1i16 , -1i64 . to_value( ) . to_i16 ( ) . expect( "invalid value" ) ) ;
461+ assert_eq ! ( -1i32 , -1i64 . to_value( ) . to_i32 ( ) . expect( "invalid value" ) ) ;
462+ assert_eq ! ( -1i64 , -1i64 . to_value( ) . to_i64 ( ) . expect( "invalid value" ) ) ;
463+ assert_eq ! ( -1isize , -1i64 . to_value( ) . to_isize ( ) . expect( "invalid value" ) ) ;
464464
465- assert ! ( 1f32 . to_value( ) . as_f32 ( ) . is_some( ) , "invalid value" ) ;
466- assert ! ( 1f64 . to_value( ) . as_f64 ( ) . is_some( ) , "invalid value" ) ;
465+ assert ! ( 1f32 . to_value( ) . to_f32 ( ) . is_some( ) , "invalid value" ) ;
466+ assert ! ( 1f64 . to_value( ) . to_f64 ( ) . is_some( ) , "invalid value" ) ;
467467
468- assert_eq ! ( 1u32 , 1i64 . to_value( ) . as_u32 ( ) . expect( "invalid value" ) ) ;
469- assert_eq ! ( 1i32 , 1u64 . to_value( ) . as_i32 ( ) . expect( "invalid value" ) ) ;
470- assert ! ( 1f32 . to_value( ) . as_i32 ( ) . is_some( ) , "invalid value" ) ;
468+ assert_eq ! ( 1u32 , 1i64 . to_value( ) . to_u32 ( ) . expect( "invalid value" ) ) ;
469+ assert_eq ! ( 1i32 , 1u64 . to_value( ) . to_i32 ( ) . expect( "invalid value" ) ) ;
470+ assert ! ( 1f32 . to_value( ) . to_i32 ( ) . is_some( ) , "invalid value" ) ;
471471
472- assert_eq ! ( 'a' , 'a' . to_value( ) . as_char ( ) . expect( "invalid value" ) ) ;
473- assert_eq ! ( true , true . to_value( ) . as_bool ( ) . expect( "invalid value" ) ) ;
472+ assert_eq ! ( 'a' , 'a' . to_value( ) . to_char ( ) . expect( "invalid value" ) ) ;
473+ assert_eq ! ( true , true . to_value( ) . to_bool ( ) . expect( "invalid value" ) ) ;
474474 }
475475}
0 commit comments