From f91c4ce73786a69e4ec72f69ef4d9d5f03ac5886 Mon Sep 17 00:00:00 2001 From: HampusM Date: Sun, 28 Aug 2022 13:24:39 +0200 Subject: style: add rustfmt config options --- src/libs/intertrait/cast/arc.rs | 3 ++- src/libs/intertrait/mod.rs | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) (limited to 'src/libs') diff --git a/src/libs/intertrait/cast/arc.rs b/src/libs/intertrait/cast/arc.rs index 65ae1ef..94c0482 100644 --- a/src/libs/intertrait/cast/arc.rs +++ b/src/libs/intertrait/cast/arc.rs @@ -23,7 +23,8 @@ pub trait CastArc ) -> Result, CastError>; } -/// A blanket implementation of `CastArc` for traits extending `CastFrom`, `Sync`, and `Send`. +/// A blanket implementation of `CastArc` for traits extending `CastFrom`, `Sync`, and +/// `Send`. impl CastArc for CastFromSelf { fn cast( diff --git a/src/libs/intertrait/mod.rs b/src/libs/intertrait/mod.rs index a8d912b..2d62871 100644 --- a/src/libs/intertrait/mod.rs +++ b/src/libs/intertrait/mod.rs @@ -7,9 +7,9 @@ //! (i.e. without involving the concrete type of the backing value) is possible //! (even no coercion from a trait object to that of its super-trait yet). //! -//! With this crate, any trait object with [`CastFrom`] as its super-trait can be cast directly -//! to another trait object implemented by the underlying type if the target traits are -//! registered beforehand with the macros provided by this crate. +//! With this crate, any trait object with [`CastFrom`] as its super-trait can be cast +//! directly to another trait object implemented by the underlying type if the target +//! traits are registered beforehand with the macros provided by this crate. //! //! //! Originally from Intertrait by CodeChain @@ -64,20 +64,21 @@ fn cast_arc_panic(_: Arc) -> Arc } /// A `Caster` knows how to cast a reference to or `Box` of a trait object for `Any` -/// to a trait object of trait `Trait`. Each `Caster` instance is specific to a concrete type. -/// That is, it knows how to cast to single specific trait implemented by single specific type. +/// to a trait object of trait `Trait`. Each `Caster` instance is specific to a concrete +/// type. That is, it knows how to cast to single specific trait implemented by single +/// specific type. /// /// An implementation of a trait for a concrete type doesn't need to manually provide /// a `Caster`. Instead attach `#[cast_to]` to the `impl` block. #[doc(hidden)] pub struct Caster { - /// Casts a `Box` holding a trait object for `Any` to another `Box` holding a trait object - /// for trait `Trait`. + /// Casts a `Box` holding a trait object for `Any` to another `Box` holding a trait + /// object for trait `Trait`. pub cast_box: fn(from: Box) -> Box, - /// Casts an `Rc` holding a trait object for `Any` to another `Rc` holding a trait object - /// for trait `Trait`. + /// Casts an `Rc` holding a trait object for `Any` to another `Rc` holding a trait + /// object for trait `Trait`. pub cast_rc: fn(from: Rc) -> Rc, /// Casts an `Arc` holding a trait object for `Any + Sync + Send + 'static` @@ -114,7 +115,8 @@ impl Caster } } -/// Returns a `Caster` from a concrete type `S` to a trait `Trait` implemented by it. +/// Returns a `Caster` from a concrete type `S` to a trait `Trait` implemented +/// by it. fn caster(type_id: TypeId) -> Option<&'static Caster> { CASTER_MAP @@ -122,10 +124,11 @@ fn caster(type_id: TypeId) -> Option<&'static Caster>()) } -/// `CastFrom` must be extended by a trait that wants to allow for casting into another trait. +/// `CastFrom` must be extended by a trait that wants to allow for casting into another +/// trait. /// -/// It is used for obtaining a trait object for [`Any`] from a trait object for its sub-trait, -/// and blanket implemented for all `Sized + Any + 'static` types. +/// It is used for obtaining a trait object for [`Any`] from a trait object for its +/// sub-trait, and blanket implemented for all `Sized + Any + 'static` types. /// /// # Examples /// ```ignore @@ -146,8 +149,9 @@ pub trait CastFrom: Any + 'static /// and wants to allow for casting into another trait behind references and smart pointers /// especially including `Arc`. /// -/// It is used for obtaining a trait object for [`Any + Sync + Send + 'static`] from an object -/// for its sub-trait, and blanket implemented for all `Sized + Sync + Send + 'static` types. +/// It is used for obtaining a trait object for [`Any + Sync + Send + 'static`] from an +/// object for its sub-trait, and blanket implemented for all `Sized + Sync + Send + +/// 'static` types. /// /// # Examples /// ```ignore -- cgit v1.2.3-18-g5258