Added frontend
All checks were successful
Rust / build_and_test (push) Successful in 2m42s

This commit is contained in:
Lukas Wölfer
2025-08-21 01:27:26 +02:00
parent aa5d621e00
commit fd5f4dd2ab
26 changed files with 1375 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
use arbitrary::{Arbitrary, Unstructured};
use canvas::{Card, CardField};
#[derive(Debug, Clone)]
pub struct RandomCard(pub(crate) Card);
#[derive(Debug)]
struct RandomCardField(CardField);
impl<'a> Arbitrary<'a> for RandomCardField {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
let i = u.int_in_range(0..=15)?;
if let Ok(w) = CardField::try_from_bits(i) {
Ok(RandomCardField(w))
} else {
Ok(RandomCardField(CardField::Empty))
}
}
}
impl<'a> Arbitrary<'a> for RandomCard {
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
let mut r = vec![];
for _ in 0..5 {
r.push(u.arbitrary::<RandomCardField>()?)
}
let w: [RandomCardField; 5] = r.try_into().unwrap();
let r = Card::from(w.map(|x: RandomCardField| x.0));
Ok(RandomCard(r))
}
}