case-studies
cargo-expand
case-studies | cargo-expand | |
---|---|---|
11 | 16 | |
1,602 | 2,435 | |
- | - | |
3.8 | 9.0 | |
about 1 month ago | 12 days ago | |
Rust | Rust | |
Apache License 2.0 | Apache License 2.0 |
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.
case-studies
-
::lending-iterator — Lending/streaming Iterators on Stable Rust (and a pinch of HKT)
Luckily there is a workaround to emulate such a definition, which dtolnay discovered and explained here: https://github.com/dtolnay/case-studies/tree/b9802f6df8dc8e54970b83fb9af6df923b46abf5/unit-type-parameters.
-
Hey Rustaceans! Got a question? Ask here! (17/2022)!
I think they are talking about this one trick which the devs don't want you to know about. Note that while it looks like specialization, it works only in a few very limited cases and is quite fragile, so it's a hack, not a substitute for the real feature.
-
Any good resources for learning Rust macros?
Also I suggest his case studies repo since you are looking at what is possible: https://github.com/dtolnay/case-studies
-
What are some creative/advanced uses of macro_rules?
/u/dtolnay has a great case studies repository.
-
Hey Rustaceans! Got an easy question? Ask here (29/2021)!
Once you have the basics down, read dtolnay's case studies. They show how to do advanced stuff with easy macros.
-
println use `Debug` if argument is not `Display`
If you were writing your own println macro, you might be able to get away with this kind of hack: https://github.com/dtolnay/case-studies/blob/master/autoref-specialization/README.md
-
Hey Rustaceans! Got an easy question? Ask here (11/2021)!
You can use "Autoref-based stable specialization" or use/mimic the impls crate.
-
Why I gave up on Rust (for now)
With a subset of specialization likely riding the trains soon and a workaround available, why would you give up?
-
Hey Rustaceans! Got an easy question? Ask here (10/2021)!
this works since values and types are in different namespaces (see: Rusts Universes or dtolnay's Case Study about "Unit struct with type parameters")
-
Hey Rustaceans! Got an easy question? Ask here (53/2020)!
To do this with traits you would need specialization but since you are using macros you should be able to use "Autoref-based stable specialization". Here is a playground which uses the latter approach to implement the wanted macro without using any nightly features.
cargo-expand
-
What is Rust doing behind the scenes?
It's been superseded by https://github.com/dtolnay/cargo-expand
-
Why dereferencing coercion is not used here?
Try installing cargo expand, it's useful to see how macros eventually get expanded. For example, if you run cargo expand on the following code
-
Procedural Macros are really hard to understand
You can use cargo expand to see what your code expands to: https://github.com/dtolnay/cargo-expand
-
[blog] Rust should own its debugger experience
Not too familiar with macros but does cargo-expand do what you want or did you mean something else?
-
Help me understand the borrowing and moving variable concept!
Yes. You can use Tools > Expand Macro on the playground or install and run cargo-expand to see what the macro expands to. It just adds a & before the argument.
- Advanced Metaprogramming in C: A select statement
-
How does declaring variables in macros work
cargo expand
-
How to see macro's source code in crate?
Along with what others are saying, there is also cargo expand which can show you what code a macro generates
-
How does Rust Python ffi work?
Something that may help you understand code with magic proc macros is this utility. It's basically a wrapper around a Rust compiler flag that allows you to expand macros for a file.
-
How does libtest know which functions are marked with #[test]?
You can use https://github.com/dtolnay/cargo-expand to examine how it works.
What are some alternatives?
rocket-auth-login - Authentication and login processing for Rust's Rocket web framework. Demonstrates a working example of how to authenticate users and process login as well as how to handle logging out.
saito-rust - A high-performance (reference) implementation of Saito in Rust
xargo - The sysroot manager that lets you build and customize `std`
proc-macro-workshop - Learn to write Rust procedural macros [Rust Latam conference, Montevideo Uruguay, March 2019]
proc-macro-crate - `$crate` in procedural macros.
lol-html - Low output latency streaming HTML parser/rewriter with CSS selector-based API
mini-redis - Incomplete Redis client and server implementation using Tokio - for learning purposes only
rust - Empowering everyone to build reliable and efficient software.
parquet2 - Fastest and safest Rust implementation of parquet. `unsafe` free. Integration-tested against pyarrow
quote - Rust quasi-quoting
tuntap-mac
cargo-llvm-cov - Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).