File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 22
33//! Generic Field Traits
44
5+ use core:: convert:: TryInto ;
56use core:: iter:: { Skip , Take } ;
67use core:: { fmt, hash, iter, ops} ;
78
@@ -153,7 +154,7 @@ pub trait Field:
153154
154155/// Trait describing a simple extension field (field obtained from another by
155156/// adjoining one element).
156- pub trait ExtensionField : Field + From < Self :: BaseField > {
157+ pub trait ExtensionField : Field + From < Self :: BaseField > + TryInto < Self :: BaseField > {
157158 /// The type of the base field.
158159 type BaseField : Field ;
159160
Original file line number Diff line number Diff line change @@ -37,6 +37,19 @@ impl<const DEG: usize> From<Fe32> for Fe32Ext<DEG> {
3737 }
3838}
3939
40+ impl < const DEG : usize > core:: convert:: TryFrom < Fe32Ext < DEG > > for Fe32 {
41+ type Error = ( ) ;
42+
43+ fn try_from ( ext : Fe32Ext < DEG > ) -> Result < Self , Self :: Error > {
44+ for elem in & ext. inner [ 1 ..] {
45+ if * elem != Fe32 :: Q {
46+ return Err ( ( ) ) ;
47+ }
48+ }
49+ Ok ( ext. inner [ 0 ] )
50+ }
51+ }
52+
4053impl < const DEG : usize > fmt:: Debug for Fe32Ext < DEG > {
4154 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result { fmt:: Display :: fmt ( self , f) }
4255}
You can’t perform that action at this time.
0 commit comments