KDAB / cxx-qt

Safe interop between Rust and Qt
https://kdab.github.io/cxx-qt/book/
1.02k stars 68 forks source link

Remove std uses in Rust where possible and use core or alloc etc #284

Open ahayzen-kdab opened 1 year ago

ahayzen-kdab commented 1 year ago

Remove uses of std:: in our generated Rust code and use core / alloc etc (and where possible CXX-Qt's code itself?).

This would bring us closer to being able to use no_std, note that CXX is already no_std https://github.com/dtolnay/cxx/blob/c7060d40361c4d955fc64adf35f67b28b5c75299/src/lib.rs#L366

ahayzen-kdab commented 1 year ago

There are some new clippy lints that could be used to automate this conversion.

https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_alloc https://rust-lang.github.io/rust-clippy/master/index.html#std_instead_of_core https://rust-lang.github.io/rust-clippy/master/index.html#alloc_instead_of_core

LeonMatthesKDAB commented 1 year ago

Note that unlike core, the alloc crate isn't added by default in Rust. We'd need to use extern crate alloc; to get it into scope, so I think using core and std is good enough for now.

Also, do we care if cxx-qt-macro is no_std? As that only runs at compile-time :thinking: Are there any use-cases where we'd want to compile on a platform that doesn't support std? Probably not...