@@ -84,6 +84,19 @@ impl<'a> View<'a> {
8484 Self :: Offset ( OffsetView :: from ( v) )
8585 }
8686 }
87+
88+ /// Convert the view to a `u128`
89+ pub fn to_u128 ( & self ) -> u128 {
90+ match self {
91+ Self :: Inline ( inline) => inline. to_u128 ( ) ,
92+ Self :: Offset ( offset) => offset. to_u128 ( ) ,
93+ }
94+ }
95+
96+ /// Return an [`OwnedView`] representing this view
97+ pub fn to_owned ( & self ) -> OwnedView {
98+ OwnedView :: new ( self . to_u128 ( ) )
99+ }
87100}
88101
89102impl < ' a > From < & ' a u128 > for View < ' a > {
@@ -233,8 +246,8 @@ impl<'a> InlineView<'a> {
233246 self . 0
234247 }
235248
236- /// Convert this inline view to a u128
237- pub fn into_u128 ( self ) -> u128 {
249+ /// Convert this view to a u128
250+ pub fn to_u128 ( & self ) -> u128 {
238251 * self . 0
239252 }
240253
@@ -300,7 +313,7 @@ impl<'a> From<InlineView<'a>> for &'a u128 {
300313impl < ' a > From < InlineView < ' a > > for u128 {
301314 #[ inline( always) ]
302315 fn from ( view : InlineView ) -> Self {
303- view. into_u128 ( )
316+ view. to_u128 ( )
304317 }
305318}
306319
@@ -337,7 +350,7 @@ impl<'a> OffsetView<'a> {
337350 self . 0
338351 }
339352
340- /// Convert this inline view to a u128
353+ /// Convert this view to a u128
341354 pub fn to_u128 ( & self ) -> u128 {
342355 * self . 0
343356 }
0 commit comments