@@ -10,24 +10,23 @@ use parse::PathParser;
10
10
11
11
use crate :: { PartialReflect , Reflect } ;
12
12
use core:: fmt;
13
- use thiserror :: Error ;
13
+ use derive_more :: derive :: { Display , From } ;
14
14
15
15
type PathResult < ' a , T > = Result < T , ReflectPathError < ' a > > ;
16
16
17
17
/// An error returned from a failed path string query.
18
- #[ derive( Debug , PartialEq , Eq , Error ) ]
18
+ #[ derive( Debug , PartialEq , Eq , Display , From ) ]
19
19
pub enum ReflectPathError < ' a > {
20
20
/// An error caused by trying to access a path that's not able to be accessed,
21
21
/// see [`AccessError`] for details.
22
- #[ error( transparent) ]
23
22
InvalidAccess ( AccessError < ' a > ) ,
24
23
25
24
/// An error that occurs when a type cannot downcast to a given type.
26
- #[ error ( "Can't downcast result of access to the given type" ) ]
25
+ #[ display ( "Can't downcast result of access to the given type" ) ]
27
26
InvalidDowncast ,
28
27
29
28
/// An error caused by an invalid path string that couldn't be parsed.
30
- #[ error ( "Encountered an error at offset {offset} while parsing `{path}`: {error}" ) ]
29
+ #[ display ( "Encountered an error at offset {offset} while parsing `{path}`: {error}" ) ]
31
30
ParseError {
32
31
/// Position in `path`.
33
32
offset : usize ,
@@ -37,11 +36,8 @@ pub enum ReflectPathError<'a> {
37
36
error : ParseError < ' a > ,
38
37
} ,
39
38
}
40
- impl < ' a > From < AccessError < ' a > > for ReflectPathError < ' a > {
41
- fn from ( value : AccessError < ' a > ) -> Self {
42
- Self :: InvalidAccess ( value)
43
- }
44
- }
39
+
40
+ impl < ' a > core:: error:: Error for ReflectPathError < ' a > { }
45
41
46
42
/// Something that can be interpreted as a reflection path in [`GetPath`].
47
43
pub trait ReflectPath < ' a > : Sized {
@@ -355,7 +351,7 @@ impl From<Access<'static>> for OffsetAccess {
355
351
/// ];
356
352
/// let my_path = ParsedPath::from(path_elements);
357
353
/// ```
358
- #[ derive( Clone , Debug , PartialEq , PartialOrd , Ord , Eq , Hash ) ]
354
+ #[ derive( Clone , Debug , PartialEq , PartialOrd , Ord , Eq , Hash , From ) ]
359
355
pub struct ParsedPath (
360
356
/// This is a vector of pre-parsed [`OffsetAccess`]es.
361
357
pub Vec < OffsetAccess > ,
@@ -447,11 +443,6 @@ impl<'a> ReflectPath<'a> for &'a ParsedPath {
447
443
Ok ( root)
448
444
}
449
445
}
450
- impl From < Vec < OffsetAccess > > for ParsedPath {
451
- fn from ( value : Vec < OffsetAccess > ) -> Self {
452
- ParsedPath ( value)
453
- }
454
- }
455
446
impl < const N : usize > From < [ OffsetAccess ; N ] > for ParsedPath {
456
447
fn from ( value : [ OffsetAccess ; N ] ) -> Self {
457
448
ParsedPath ( value. to_vec ( ) )
0 commit comments