Skip to content

Commit ce7a285

Browse files
stepanchegfacebook-github-bot
authored andcommitted
ValueOf::as_unchecked
Summary: Safe conversion. Reviewed By: JakobDegen Differential Revision: D59615564 fbshipit-source-id: 6e1b480d2f87eb7838fdec92fdcf6fbf38b3325d
1 parent 890d1bb commit ce7a285

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

starlark/src/values/value_of.rs

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use crate::values::AllocValue;
2525
use crate::values::Heap;
2626
use crate::values::UnpackValue;
2727
use crate::values::Value;
28+
use crate::values::ValueOfUnchecked;
2829

2930
/// A wrapper that keeps the original value on the heap for use elsewhere,
3031
/// and also, when unpacked, unpacks the value to validate it is of
@@ -39,6 +40,13 @@ pub struct ValueOf<'v, T: UnpackValue<'v>> {
3940
pub typed: T,
4041
}
4142

43+
impl<'v, T: UnpackValue<'v>> ValueOf<'v, T> {
44+
/// Convert to `ValueOfUnchecked`.
45+
pub fn as_unchecked(&self) -> ValueOfUnchecked<'v, T> {
46+
ValueOfUnchecked::new(self.value)
47+
}
48+
}
49+
4250
impl<'v, T: UnpackValue<'v>> Deref for ValueOf<'v, T> {
4351
type Target = Value<'v>;
4452

0 commit comments

Comments
 (0)