Skip to content

Commit

Permalink
Use nightly rustfmt to format imports (#838)
Browse files Browse the repository at this point in the history
  • Loading branch information
PoignardAzur authored Jan 20, 2025
1 parent fc0acae commit 066d431
Show file tree
Hide file tree
Showing 43 changed files with 211 additions and 238 deletions.
4 changes: 2 additions & 2 deletions tree_arena/src/tree_arena_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
//! will use an arena and unsafe code, but should have the exact same exported API as
//! this module.
use super::NodeId;

use hashbrown::HashMap;

use crate::NodeId;

#[derive(Debug)]
struct TreeNode<T> {
id: NodeId,
Expand Down
4 changes: 2 additions & 2 deletions tree_arena/src/tree_arena_unsafe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// SPDX-License-Identifier: Apache-2.0

#![allow(unsafe_code, reason = "Purpose is unsafe abstraction")]
use super::NodeId;

use std::cell::UnsafeCell;

use hashbrown::HashMap;

use crate::NodeId;

#[derive(Debug)]
struct TreeNode<T> {
item: T,
Expand Down
9 changes: 4 additions & 5 deletions xilem/examples/emoji_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
#![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")]

use winit::error::EventLoopError;
use xilem::{
core::map_state,
palette,
view::{button, flex, grid, label, prose, sized_box, Axis, FlexExt, FlexSpacer, GridExt},
Color, EventLoop, EventLoopBuilder, WidgetView, Xilem,
use xilem::core::map_state;
use xilem::view::{
button, flex, grid, label, prose, sized_box, Axis, FlexExt, FlexSpacer, GridExt,
};
use xilem::{palette, Color, EventLoop, EventLoopBuilder, WidgetView, Xilem};

fn app_logic(data: &mut EmojiPagination) -> impl WidgetView<EmojiPagination> {
flex((
Expand Down
6 changes: 2 additions & 4 deletions xilem/src/view/transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

use std::marker::PhantomData;

use crate::{
core::{DynMessage, View, ViewMarker},
Affine, Pod, ViewCtx, WidgetView,
};
use crate::core::{DynMessage, View, ViewMarker};
use crate::{Affine, Pod, ViewCtx, WidgetView};

/// A view which transforms the widget created by child.
///
Expand Down
3 changes: 1 addition & 2 deletions xilem/src/view/variable_label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ use masonry::{widget, TextAlignment};
use vello::peniko::Brush;
use xilem_core::ViewPathTracker;

use super::{label, Label};
use crate::core::{DynMessage, Mut, ViewMarker};
use crate::{MessageResult, Pod, View, ViewCtx, ViewId};

use super::{label, Label};

/// A view for displaying non-editable text, with a variable [weight](masonry::parley::style::FontWeight).
pub fn variable_label(text: impl Into<ArcStr>) -> VariableLabel {
VariableLabel {
Expand Down
19 changes: 8 additions & 11 deletions xilem/src/view/zstack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@

use std::marker::PhantomData;

use crate::{
core::{
AppendVec, DynMessage, ElementSplice, Mut, SuperElement, View, ViewElement, ViewMarker,
ViewSequence,
},
Pod, ViewCtx, WidgetView,
};
use masonry::{
widget::{self, Alignment, ChildAlignment, WidgetMut},
FromDynWidget, Widget,
};
use masonry::widget::{self, Alignment, ChildAlignment, WidgetMut};
use masonry::{FromDynWidget, Widget};
use xilem_core::{MessageResult, ViewId};

use crate::core::{
AppendVec, DynMessage, ElementSplice, Mut, SuperElement, View, ViewElement, ViewMarker,
ViewSequence,
};
use crate::{Pod, ViewCtx, WidgetView};

/// A widget that lays out its children on top of each other.
/// The children are laid out back to front.
///
Expand Down
3 changes: 2 additions & 1 deletion xilem_core/src/views/map_action.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use core::{fmt::Debug, marker::PhantomData};
use core::fmt::Debug;
use core::marker::PhantomData;

use crate::{Mut, View, ViewId, ViewMarker, ViewPathTracker};

Expand Down
3 changes: 2 additions & 1 deletion xilem_core/src/views/map_state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use core::{fmt::Debug, marker::PhantomData};
use core::fmt::Debug;
use core::marker::PhantomData;

use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};

Expand Down
3 changes: 2 additions & 1 deletion xilem_core/src/views/memoize.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use core::fmt::Debug;
use core::marker::PhantomData;
use core::mem::size_of;
use core::{fmt::Debug, marker::PhantomData};

use crate::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};

Expand Down
6 changes: 2 additions & 4 deletions xilem_web/src/after_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

use std::marker::PhantomData;

use crate::{
core::{MessageResult, Mut, View, ViewId, ViewMarker},
DomNode, DomView, DynMessage, ViewCtx,
};
use crate::core::{MessageResult, Mut, View, ViewId, ViewMarker};
use crate::{DomNode, DomView, DynMessage, ViewCtx};

/// Invokes the `callback` after the inner `element` [`DomView`] was created.
/// See [`after_build`] for more details.
Expand Down
13 changes: 7 additions & 6 deletions xilem_web/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// Copyright 2023 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{
core::{AppendVec, MessageResult, ViewId},
elements::DomChildrenSplice,
AnyPod, DomFragment, DynMessage, ViewCtx,
};
use std::{cell::RefCell, rc::Rc};
use std::cell::RefCell;
use std::rc::Rc;

use wasm_bindgen::UnwrapThrowExt;

use crate::core::{AppendVec, MessageResult, ViewId};
use crate::elements::DomChildrenSplice;
use crate::{AnyPod, DomFragment, DynMessage, ViewCtx};

pub(crate) struct AppMessage {
pub id_path: Rc<[ViewId]>,
pub body: DynMessage,
Expand Down
11 changes: 6 additions & 5 deletions xilem_web/src/concurrent/interval.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
// Copyright 2024 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{
core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker},
DynMessage, OptionalAction, ViewCtx,
};
use std::marker::PhantomData;
use wasm_bindgen::{closure::Closure, JsCast, UnwrapThrowExt};

use wasm_bindgen::closure::Closure;
use wasm_bindgen::{JsCast, UnwrapThrowExt};

use crate::core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker};
use crate::{DynMessage, OptionalAction, ViewCtx};

/// Start an interval which invokes `callback` every `ms` milliseconds
pub struct Interval<Callback, State, Action> {
Expand Down
14 changes: 8 additions & 6 deletions xilem_web/src/concurrent/memoized_await.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Copyright 2024 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{
core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker, ViewPathTracker},
DynMessage, OptionalAction, ViewCtx,
};
use std::{future::Future, marker::PhantomData};
use wasm_bindgen::{closure::Closure, JsCast, UnwrapThrowExt};
use std::future::Future;
use std::marker::PhantomData;

use wasm_bindgen::closure::Closure;
use wasm_bindgen::{JsCast, UnwrapThrowExt};
use wasm_bindgen_futures::spawn_local;

use crate::core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker, ViewPathTracker};
use crate::{DynMessage, OptionalAction, ViewCtx};

/// Await a future returned by `init_future` invoked with the argument `data`, `callback` is called with the output of the future. `init_future` will be invoked again, when `data` changes. Use [`memoized_await`] for construction of this [`View`]
pub struct MemoizedAwait<State, Action, OA, InitFuture, Data, Callback, F, FOut> {
init_future: InitFuture,
Expand Down
18 changes: 10 additions & 8 deletions xilem_web/src/concurrent/task.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use std::{future::Future, marker::PhantomData, rc::Rc};

use crate::{
context::MessageThunk,
core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker},
DynMessage, Message, ViewCtx,
};
use futures::{channel::oneshot, FutureExt};
use std::future::Future;
use std::marker::PhantomData;
use std::rc::Rc;

use futures::channel::oneshot;
use futures::FutureExt;
use wasm_bindgen::UnwrapThrowExt;
use wasm_bindgen_futures::spawn_local;

use crate::context::MessageThunk;
use crate::core::{MessageResult, Mut, NoElement, View, ViewId, ViewMarker};
use crate::{DynMessage, Message, ViewCtx};

/// Spawn an async task to update state asynchronously
///
/// The `init_future` function is given a [`TaskProxy`] and a [`ShutdownSignal`].
Expand Down
15 changes: 6 additions & 9 deletions xilem_web/src/context.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use std::any::{Any, TypeId};
use std::rc::Rc;

use wasm_bindgen_futures::spawn_local;

use crate::app::{AppMessage, AppRunner};
use crate::core::{ViewId, ViewPathTracker};
use crate::vecmap::VecMap;
use std::any::Any;
use std::any::TypeId;
use std::rc::Rc;

use crate::{
app::{AppMessage, AppRunner},
core::{ViewId, ViewPathTracker},
Message,
};
use crate::Message;

/// A thunk to send messages to the views, it's being used for example in event callbacks
pub struct MessageThunk {
Expand Down
13 changes: 7 additions & 6 deletions xilem_web/src/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@

//! Basic builder functions to create DOM elements, such as [`html::div`]
use std::any::Any;
use std::borrow::Cow;
use std::marker::PhantomData;
use std::{any::Any, rc::Rc};
use std::rc::Rc;

use wasm_bindgen::{JsCast, UnwrapThrowExt};

use crate::core::{AppendVec, ElementSplice, MessageResult, Mut, View, ViewId, ViewMarker};
use crate::modifiers::Children;
use crate::vec_splice::VecSplice;
use crate::{
core::{AppendVec, ElementSplice, MessageResult, Mut, View, ViewId, ViewMarker},
document,
modifiers::Children,
vec_splice::VecSplice,
AnyPod, DomFragment, DomNode, DynMessage, FromWithContext, Pod, ViewCtx, HTML_NS,
document, AnyPod, DomFragment, DomNode, DynMessage, FromWithContext, Pod, ViewCtx, HTML_NS,
};

// sealed, because this should only cover `ViewSequences` with the blanket impl below
Expand Down
14 changes: 8 additions & 6 deletions xilem_web/src/events.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// Copyright 2023 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{
core::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker},
DomView, DynMessage, OptionalAction, ViewCtx,
};
use std::{borrow::Cow, marker::PhantomData};
use wasm_bindgen::{prelude::Closure, throw_str, JsCast, UnwrapThrowExt};
use std::borrow::Cow;
use std::marker::PhantomData;

use wasm_bindgen::prelude::Closure;
use wasm_bindgen::{throw_str, JsCast, UnwrapThrowExt};
use web_sys::{js_sys, AddEventListenerOptions};

use crate::core::{MessageResult, Mut, View, ViewId, ViewMarker, ViewPathTracker};
use crate::{DomView, DynMessage, OptionalAction, ViewCtx};

/// Use a distinctive number here, to be able to catch bugs.
/// In case the generational-id view path in `View::Message` lead to a wrong view
const ON_EVENT_VIEW_ID: ViewId = ViewId::new(0x2357_1113);
Expand Down
10 changes: 4 additions & 6 deletions xilem_web/src/interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
use std::borrow::Cow;

use crate::{
events,
modifiers::{Attr, Class, ClassIter, Rotate, Scale, ScaleValue, Style, StyleIter},
props::{WithElementProps, WithHtmlInputElementProps},
DomNode, DomView, IntoAttributeValue, OptionalAction, Pointer, PointerMsg,
};
use wasm_bindgen::JsCast;

use crate::modifiers::{Attr, Class, ClassIter, Rotate, Scale, ScaleValue, Style, StyleIter};
use crate::props::{WithElementProps, WithHtmlInputElementProps};
use crate::{events, DomNode, DomView, IntoAttributeValue, OptionalAction, Pointer, PointerMsg};

macro_rules! event_handler_mixin {
($(($event_ty: ident, $fn_name:ident, $event:expr, $web_sys_event_type:ident),)*) => {
$(
Expand Down
4 changes: 3 additions & 1 deletion xilem_web/src/message.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use std::{any::Any, fmt::Debug, ops::Deref};
use std::any::Any;
use std::fmt::Debug;
use std::ops::Deref;

/// A dynamically typed message for the [`View`] trait.
///
Expand Down
12 changes: 6 additions & 6 deletions xilem_web/src/modifiers/attribute.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{
core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker},
modifiers::{Modifier, WithModifier},
vecmap::VecMap,
AttributeValue, DomView, DynMessage, IntoAttributeValue, ViewCtx,
};
use std::marker::PhantomData;

use wasm_bindgen::{JsCast, UnwrapThrowExt};

use crate::core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker};
use crate::modifiers::{Modifier, WithModifier};
use crate::vecmap::VecMap;
use crate::{AttributeValue, DomView, DynMessage, IntoAttributeValue, ViewCtx};

type CowStr = std::borrow::Cow<'static, str>;

#[derive(Debug, PartialEq, Clone)]
Expand Down
17 changes: 9 additions & 8 deletions xilem_web/src/modifiers/class.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
// Copyright 2024 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

use crate::{
core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker},
diff::{diff_iters, Diff},
modifiers::{Modifier, WithModifier},
vecmap::VecMap,
DomView, DynMessage, ViewCtx,
};
use std::{fmt::Debug, marker::PhantomData};
use std::fmt::Debug;
use std::marker::PhantomData;

use wasm_bindgen::{JsCast, UnwrapThrowExt};

use crate::core::{MessageResult, Mut, View, ViewElement, ViewId, ViewMarker};
use crate::diff::{diff_iters, Diff};
use crate::modifiers::{Modifier, WithModifier};
use crate::vecmap::VecMap;
use crate::{DomView, DynMessage, ViewCtx};

type CowStr = std::borrow::Cow<'static, str>;

#[derive(Debug, PartialEq, Clone)]
Expand Down
3 changes: 1 addition & 2 deletions xilem_web/src/modifiers/overwrite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,8 @@ macro_rules! overwrite_bool_modifier_view {

#[cfg(test)]
mod tests {
use crate::PodFlags;

use super::*;
use crate::PodFlags;

#[test]
fn overwrite_bool_push() {
Expand Down
Loading

0 comments on commit 066d431

Please sign in to comment.