Replies: 1 comment
-
Hi @zakhenry -- thanks for your interest and this fun example! Yes, we have a bunch of other examples lined up but had to hold them since the paper was under review. Your example can be simplified a bit as instead of
like so: #[flux::sig(fn(width:i32{width > 0}, height:i32{height > 0}) -> Canvas[width, height])]
pub fn new(width: i32, height: i32) -> Canvas {
Canvas{ width, height }
}
#[flux::sig(fn(&mut Canvas[@w, @h], x:i32{x >= 0 && x <= w - 1}, y:i32{y >= 0 && y <= h - 1}, bool))]
fn set_pixel(&mut self, x: i32, y: i32, on: bool) {
// todo implement
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just watched the talk linked in reddit (https://www.reddit.com/r/rust/comments/13l6s4l/liquid_types_for_rust/) and found the discussion about the meaningfulness of the declared parameters for the struct
refined_by
macro to be quite valid as it was a little confusing. I tried to make sense of it from the docs but alas there no page on structs just yet. Had a stab at getting it working in the playground with a somewhat real world solution and I think I got there in the end (at least I'm getting errors when I expect them). Is there a cleaner way that I could achieve this same outcome?I feel like the refinement signature on
set_pixel
can probably be simplified?Also feel free to use this example in the docs if it helps any, I was trying to come up with an example that should be somewhat familiar to most developers and would feel more "real world". Hoping to show this awesome initiative off to colleagues and coming up with some examples to get them excited 😁
Beta Was this translation helpful? Give feedback.
All reactions