Skip to content

WIP: Rust Experiments #852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

WIP: Rust Experiments #852

wants to merge 6 commits into from

Conversation

johannes-wolf
Copy link
Member

@johannes-wolf johannes-wolf commented Mar 28, 2025

Some tests.

@johannes-wolf
Copy link
Member Author

johannes-wolf commented Mar 28, 2025

@rikhuijzer: Sume Rust experiments for modifying complete paths on the Rust side.
One problem I could not solve is Points with integers instead of floats. Serde fails if the "wrong" type is in the cbor and there seems to be no option to accept ints where floats are expected.

With serde_tuple I don't think we need to change everything to dicts.

@johannes-wolf johannes-wolf changed the base branch from master to wip-path-refactoring March 28, 2025 15:22
#[derive(Serialize,Deserialize)]
#[serde(untagged)]
enum Segment {
Line(String /* "l" */, Point),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is ugly.

use wasm_minimal_protocol::*;

initiate_protocol!();

type Point = Vec<f64>;
type Point = ArrayVec<f64, 4>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this is great. I was also thinking about something like this

@rikhuijzer
Copy link
Contributor

Experimenting. I like it

Serde fails if the "wrong" type is in the cbor and there seems to be no option to accept ints where floats are expected.

Yes I also ran into this a few times. This is Rust’s blessing and curse I think. I was fixing it by trying to be more strict at the Typst side. I fixed one int case in I believe #849 (on phone now so can’t check) which didn’t seem too bad. Naja I’m also open to other ideas these were just my 2 cents

@rikhuijzer
Copy link
Contributor

I think static typing is a massive improvement in programming in general, but people are allowed to disagree with me on this one

@johannes-wolf johannes-wolf force-pushed the wip-path-refactoring branch 4 times, most recently from 5651c33 to e317f7c Compare May 9, 2025 18:47
@johannes-wolf johannes-wolf force-pushed the wip-path-refactoring branch 12 times, most recently from 7fb3a2a to f95c1f2 Compare May 30, 2025 01:28
Base automatically changed from wip-path-refactoring to master May 30, 2025 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants