Our great sponsors
-
Clippy
A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
In a previous PR to clippy, an suggestion from the maintainers (@flip1995) came up to create a lint detecting passing an owned string to something expecting where "" would be accepted. I want to follow up on this and open an issue (and perhaps a PR) to implement this, but first I want to make sure I'm not missing anything.
There are ways to enforce it, for example declaring the variable const or static, or using the nightly feature inline_const: https://github.com/rust-lang/rust/issues/76001 which would allow you to write let s = const { String::new() };, ensuring that everything from inside the const block is evaluated at compile time.