问题标签 [rust-2021]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
rust - Can Rust macros be shared across editions?
Say a Rust 2018 macro defines an async
function inside it. The syntax it would use would be incompatible with Rust 2015. So if you're compiling your crate with 2015 edition, wouldn't this expanded code from the macro conflict with that?
I'm not that familiar with inner workings of either procedural or declarative macros, but I imagine they need to produce edition-specific code, because their output is going to be treated the same as the rest of the code. If so, how can I share macro exports across edition boundaries. Do I need to re-write them on a per-edition basis? That doesn't seem scalable especially if editions are supposed to be released every 3 years or so.
rust - 更新“rustc”后,“use std::io”可以破坏我的代码吗?
我在 C++ 课后为了好玩而学习 rust,我想知道,在将版本use std::io
更新为新版本后会破坏我的代码rustc
吗?
例如,在 C++ 中使用using namespace std
是不好的,因为如果将新函数添加到std
您的多个翻译单元中,则编译器更新后代码可能会中断,因为与您编写的函数名称相同的函数已添加到 namespace std
。
但是在所有官方的 rust 教程use std::io
中都使用了。
可以use std::io
破坏我的代码生锈吗?