luau 0.732.0

Safe lifetime-bound Rust embedding API for the Luau runtime
use super::super::MacroCounter;
use luau::{Error, Result};

#[luau::userdata_impl]
impl MacroCounter {
    #[luau(get, name = "doubled", infallible)]
    fn doubled(&self) -> i32 {
        self.value * 2
    }

    #[luau(get, name = "positive", infallible)]
    fn positive(&self) -> i32 {
        self.value
    }

    #[luau(set, name = "positive")]
    fn set_positive(&mut self, value: i32) -> Result<()> {
        if value < 0 {
            return Err(Error::runtime("value must be nonnegative"));
        }
        self.value = value;
        Ok(())
    }
}