ceylon-lang.org
cheats.rs
ceylon-lang.org | cheats.rs | |
---|---|---|
1 | 3 | |
52 | 3,926 | |
- | - | |
10.0 | 8.2 | |
over 3 years ago | 15 days ago | |
HTML | Rust | |
- | - |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
ceylon-lang.org
-
Using enums to represent state in Rust
> One thing Rust could really use are anonymous unions (A | B |C instead of E::A(A), E::B(B), E::C(C)). They are to enums what tuple types are to structs.
Ceylon had union types, which is the only place i've seen these: https://github.com/eclipse-archived/ceylon-lang.org/blob/mas...
Another thing Rust enums are missing is having each variant be a type. If you have an enum Shape with variants Circle, Rectangle, and Polygon, there is no way to write a function which only takes a Circle. So you end up defining a struct for each case, then making your enum a trivial wrapper round the three structs. You end up with Shape::Circle and Circle, which are different things, and writing code like c.0.radius to get at the fields. It's rather inelegant. So either variants should be types in their own right, or an enum should be defined as a composition of existing types.
cheats.rs
-
Using enums to represent state in Rust
Reposting: https://cheats.rs/#memory-layout
> Does the value take up the same width regardless of state?
Yes. As the other commenter mentioned, it's the size of the largest variant (same as a union in C) + a tag (almost the same as an enum in C). In some cases, the compiler even manages to optimize out the tag.
-
Rust Language Cheat Sheet
> Is it just me or the output PDF has quite a bit of broken pages
Nope! The breaks are really there. I guess they converted the HTML to PDF somehow and it didn't work as expected. However in case you need it offline, the source [1] is written for zola [2] - a single-binary static site generator (of course written in Rust). You can clone the repo and run `zola serve` in it. It renders quite well.
[1] https://github.com/ralfbiedert/cheats.rs/
[2] https://www.getzola.org/
What are some alternatives?
higher-kinded-lifecycle - A demonstration of an idea about how to represent the lifecycle of entities in Scala using higher-kinded types
runwasi - Facilitates running Wasm / WASI workloads managed by containerd
RustPython - A Python Interpreter written in Rust
slint - Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
rust - Empowering everyone to build reliable and efficient software.