Currently we generate:
#[derive(Default)]
pub struct woff2_Point {
pub x: Value<i32>,
pub y: Value<i32>,
pub on_curve: Value<bool>,
}
impl Clone for woff2_Point {
fn clone(&self) -> Self {
let mut this = Self {
x: Rc::new(RefCell::new((*self.x.borrow()))),
y: Rc::new(RefCell::new((*self.y.borrow()))),
on_curve: Rc::new(RefCell::new((*self.on_curve.borrow()))),
};
this
}
}
impl ByteRepr for woff2_Point {
fn to_bytes(&self, buf: &mut [u8]) {
(*self.x.borrow()).to_bytes(&mut buf[0..4]);
(*self.y.borrow()).to_bytes(&mut buf[4..8]);
(*self.on_curve.borrow()).to_bytes(&mut buf[8..9]);
}
fn from_bytes(buf: &[u8]) -> Self {
Self {
x: Rc::new(RefCell::new(<i32>::from_bytes(&buf[0..4]))),
y: Rc::new(RefCell::new(<i32>::from_bytes(&buf[4..8]))),
on_curve: Rc::new(RefCell::new(<bool>::from_bytes(&buf[8..9]))),
}
}
}
That's a lot of code. We can write 2 proc-macros: DeepClone and ByteRepr and generate the following code instead:
#[derive(Default, DeepClone, ByteRepr)]
pub struct woff2_Point {
pub x: Value<i32>,
pub y: Value<i32>,
pub on_curve: Value<bool>,
}
Currently we generate:
That's a lot of code. We can write 2 proc-macros:
DeepCloneandByteReprand generate the following code instead: