File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -190,6 +190,15 @@ impl Value {
190190 _ => false ,
191191 }
192192 }
193+
194+ /// Returns the explicit value.
195+ /// Returns [None] if [is_explicit] returns false.
196+ pub fn explicit ( & self ) -> Option < u64 > {
197+ match * self {
198+ Value :: Explicit ( v) => Some ( v) ,
199+ _ => None ,
200+ }
201+ }
193202}
194203
195204/// A CT commitment to an asset
@@ -221,6 +230,15 @@ impl Asset {
221230 _ => false ,
222231 }
223232 }
233+
234+ /// Unwrap the explicit value of this type.
235+ /// Panics if [is_explicit] returns false.
236+ pub fn unwrap_explicit ( & self ) -> sha256d:: Hash {
237+ match * self {
238+ Asset :: Explicit ( v) => v,
239+ _ => panic ! ( "Called unwrap_explicit on non-explicit asset: {:?}" , self ) ,
240+ }
241+ }
224242}
225243
226244
@@ -255,6 +273,15 @@ impl Nonce {
255273 _ => false ,
256274 }
257275 }
276+
277+ /// Unwrap the explicit value of this type.
278+ /// Panics if [is_explicit] returns false.
279+ pub fn unwrap_explicit ( & self ) -> sha256d:: Hash {
280+ match * self {
281+ Nonce :: Explicit ( v) => v,
282+ _ => panic ! ( "Called unwrap_explicit on non-explicit nonce: {:?}" , self ) ,
283+ }
284+ }
258285}
259286
260287#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments