Janitor: Always use `#![no_std] for runtime lib

And call `extern crate std` when the feature is enabled.
I've read this is the good practice on how to do it.
So that the std prelude is no longer included automatically.
There is then less difference between std and and no-std build which
should avoid surprises in the CI when we use things from the prelude.

The downside is that there is a bit of churn in the tests
This commit is contained in:
Olivier Goffart 2025-01-27 18:02:37 +01:00
parent e24e9ffb60
commit c98d234b9e
47 changed files with 112 additions and 129 deletions

View file

@ -3,8 +3,10 @@
/*! This crate just expose the function used by the C++ integration */
#![cfg_attr(not(feature = "std"), no_std)]
#![no_std]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
use alloc::rc::Rc;
use core::ffi::c_void;

View file

@ -2,7 +2,6 @@
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
use alloc::rc::Rc;
#[cfg(not(feature = "std"))]
use alloc::{boxed::Box, string::String};
use core::ffi::c_void;
use i_slint_core::api::{