From 33d20763c841767faf77baf853194c22a7bfa459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 3 Apr 2025 20:27:17 +0200 Subject: [PATCH] Annotate root crate tests with `standalone_crate` The new Rustdoc combined tests are an order of magnitude slower in my machine for the `iced` root crate. --- src/application.rs | 4 ++-- src/lib.rs | 32 ++++++++++++++++---------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/application.rs b/src/application.rs index c79ed62b..c220131a 100644 --- a/src/application.rs +++ b/src/application.rs @@ -1,7 +1,7 @@ //! Create and run iced applications step by step. //! //! # Example -//! ```no_run +//! ```no_run,standalone_crate //! use iced::widget::{button, column, text, Column}; //! use iced::Theme; //! @@ -42,7 +42,7 @@ use std::borrow::Cow; /// Creates an iced [`Application`] given its title, update, and view logic. /// /// # Example -/// ```no_run +/// ```no_run,standalone_crate /// use iced::widget::{button, column, text, Column}; /// /// pub fn main() -> iced::Result { diff --git a/src/lib.rs b/src/lib.rs index 21543fac..3ad685fa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ //! # The Pocket Guide //! Start by calling [`run`]: //! -//! ```rust,no_run +//! ```no_run,standalone_crate //! pub fn main() -> iced::Result { //! iced::run("A cool counter", update, view) //! } @@ -39,7 +39,7 @@ //! //! Define an `update` function to __change__ your state: //! -//! ```rust +//! ```standalone_crate //! fn update(counter: &mut u64, message: Message) { //! match message { //! Message::Increment => *counter += 1, @@ -51,7 +51,7 @@ //! //! Define a `view` function to __display__ your state: //! -//! ```rust +//! ```standalone_crate //! use iced::widget::{button, text}; //! use iced::Element; //! @@ -64,7 +64,7 @@ //! //! And create a `Message` enum to __connect__ `view` and `update` together: //! -//! ```rust +//! ```standalone_crate //! #[derive(Debug, Clone)] //! enum Message { //! Increment, @@ -74,7 +74,7 @@ //! ## Custom State //! You can define your own struct for your state: //! -//! ```rust +//! ```standalone_crate //! #[derive(Default)] //! struct Counter { //! value: u64, @@ -83,7 +83,7 @@ //! //! But you have to change `update` and `view` accordingly: //! -//! ```rust +//! ```standalone_crate //! # struct Counter { value: u64 } //! # #[derive(Clone)] //! # enum Message { Increment } @@ -108,7 +108,7 @@ //! //! Widgets are configured using the builder pattern: //! -//! ```rust +//! ```standalone_crate //! # struct Counter { value: u64 } //! # #[derive(Clone)] //! # enum Message { Increment } @@ -138,7 +138,7 @@ //! Building your layout will often consist in using a combination of //! [rows], [columns], and [containers]: //! -//! ```rust +//! ```standalone_crate //! # struct State; //! # enum Message {} //! use iced::widget::{column, container, row}; @@ -181,7 +181,7 @@ //! //! A fixed numeric [`Length`] in [`Pixels`] can also be used: //! -//! ```rust +//! ```standalone_crate //! # struct State; //! # enum Message {} //! use iced::widget::container; @@ -197,7 +197,7 @@ //! function and leveraging the [`Application`] builder, instead of directly //! calling [`run`]: //! -//! ```rust,no_run +//! ```no_run,standalone_crate //! # #[derive(Default)] //! # struct State; //! use iced::Theme; @@ -227,7 +227,7 @@ //! //! The appearance of a widget can be changed by calling its `style` method: //! -//! ```rust +//! ```standalone_crate //! # struct State; //! # enum Message {} //! use iced::widget::container; @@ -241,7 +241,7 @@ //! The `style` method of a widget takes a closure that, given the current active //! [`Theme`], returns the widget style: //! -//! ```rust +//! ```standalone_crate //! # struct State; //! # #[derive(Clone)] //! # enum Message {} @@ -286,7 +286,7 @@ //! A [`Task`] can be leveraged to perform asynchronous work, like running a //! future or a stream: //! -//! ```rust +//! ```standalone_crate //! # #[derive(Clone)] //! # struct Weather; //! use iced::Task; @@ -334,7 +334,7 @@ //! //! You will need to define a `subscription` function and use the [`Application`] builder: //! -//! ```rust,no_run +//! ```no_run,standalone_crate //! # #[derive(Default)] //! # struct State; //! use iced::window; @@ -375,7 +375,7 @@ //! A common pattern is to leverage this composability to split an //! application into different screens: //! -//! ```rust +//! ```standalone_crate //! # mod contacts { //! # use iced::{Element, Task}; //! # pub struct Contacts; @@ -656,7 +656,7 @@ pub type Result = std::result::Result<(), Error>; /// This is equivalent to chaining [`application()`] with [`Application::run`]. /// /// # Example -/// ```no_run +/// ```no_run,standalone_crate /// use iced::widget::{button, column, text, Column}; /// /// pub fn main() -> iced::Result {