Skip to content

Commit

Permalink
impl UnpackValue for (,,)
Browse files Browse the repository at this point in the history
Summary: Used later, good as is.

Reviewed By: JakobDegen

Differential Revision: D53929129

fbshipit-source-id: cf63c721cf1f6148241f207ab7b279b06d78ec86
  • Loading branch information
stepancheg authored and facebook-github-bot committed Feb 20, 2024
1 parent 21c72b3 commit 3ace4fb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions starlark/src/values/types/tuple/rust_tuple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,28 @@ impl<'v, T1: UnpackValue<'v>, T2: UnpackValue<'v>> UnpackValue<'v> for (T1, T2)
))
}
}

impl<'v, T1: UnpackValue<'v>, T2: UnpackValue<'v>, T3: UnpackValue<'v>> UnpackValue<'v>
for (T1, T2, T3)
{
fn expected() -> String {
format!(
"tuple ({}, {}, {})",
T1::expected(),
T2::expected(),
T3::expected()
)
}

fn unpack_value(value: Value<'v>) -> Option<Self> {
let t = Tuple::from_value(value)?;
if t.len() != 3 {
return None;
}
Some((
T1::unpack_value(t.content()[0])?,
T2::unpack_value(t.content()[1])?,
T3::unpack_value(t.content()[2])?,
))
}
}

0 comments on commit 3ace4fb

Please sign in to comment.