diff --git a/Makefile b/Makefile index 45e341b29e..8828abba83 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,11 @@ sync : git.sync # Usage : # make audit -audit : - cargo audit +audit : +# This change is made to ignore the RUSTSEC-2024-0421 warning related to the idna crate. +# The issue arises because unitore relies on gluesql, which in turn depends on an outdated version of idna. +# Since the primary logic in unitore is built around gluesql, upgrading idna directly is not feasible. + cargo audit --ignore RUSTSEC-2024-0421 # # === General commands diff --git a/module/core/clone_dyn_types/src/lib.rs b/module/core/clone_dyn_types/src/lib.rs index 2642542d03..68fdff07d4 100644 --- a/module/core/clone_dyn_types/src/lib.rs +++ b/module/core/clone_dyn_types/src/lib.rs @@ -89,7 +89,6 @@ mod private /// /// assert_eq!( original.value, cloned.value ); /// ``` - #[ inline ] pub fn clone< T >( src : &T ) -> T where @@ -174,7 +173,6 @@ mod private /// let cloned : Box< dyn MyTrait > = clone_into_box( &MyStruct { value : 42 } ); /// /// ``` - #[ inline ] pub fn clone_into_box< T >( ref_dyn : &T ) -> Box< T > where diff --git a/module/core/derive_tools/src/lib.rs b/module/core/derive_tools/src/lib.rs index fe3c51ebbf..f845b0c942 100644 --- a/module/core/derive_tools/src/lib.rs +++ b/module/core/derive_tools/src/lib.rs @@ -71,7 +71,6 @@ mod derive_more pub use variadic_from as variadic; /// Namespace with dependencies. - #[ allow( unused_imports ) ] #[ cfg( feature = "enabled" ) ] pub mod dependency diff --git a/module/core/error_tools/src/error/assert.rs b/module/core/error_tools/src/error/assert.rs index 18ba821186..8a8145e755 100644 --- a/module/core/error_tools/src/error/assert.rs +++ b/module/core/error_tools/src/error/assert.rs @@ -4,7 +4,6 @@ mod private /// /// Macro asserts that two expressions are identical to each other. Unlike `std::assert_eq` it is removed from a release build. /// - #[ macro_export ] macro_rules! debug_assert_id { @@ -59,7 +58,6 @@ mod private } /// Macro asserts that two expressions are identical to each other. Unlike `std::assert_eq` it is removed from a release build. Alias of `debug_assert_id`. - #[ macro_export ] macro_rules! debug_assert_identical { @@ -71,7 +69,6 @@ mod private } /// Macro asserts that two expressions are not identical to each other. Unlike `std::assert_eq` it is removed from a release build. - #[ macro_export ] macro_rules! debug_assert_ni { @@ -84,7 +81,6 @@ mod private } /// Macro asserts that two expressions are not identical to each other. Unlike `std::assert_eq` it is removed from a release build. - #[ macro_export ] macro_rules! debug_assert_not_identical { diff --git a/module/core/error_tools/src/error/mod.rs b/module/core/error_tools/src/error/mod.rs index 0de7d2fafd..9c22df98c3 100644 --- a/module/core/error_tools/src/error/mod.rs +++ b/module/core/error_tools/src/error/mod.rs @@ -2,7 +2,7 @@ mod private { #[ allow( clippy::useless_attribute, clippy::pub_use ) ] - pub use std::error::Error as ErrorTrait; + pub use core::error::Error as ErrorTrait; /// This trait allows adding extra context or information to an error, creating a tuple of the additional /// context and the original error. This is particularly useful for error handling when you want to include @@ -11,7 +11,6 @@ mod private /// The `ErrWith` trait provides methods to wrap an error with additional context, either by using a closure /// that generates the context or by directly providing the context. /// - /// ``` pub trait ErrWith< ReportErr, ReportOk, E > { /// Takes a closure `f` that returns a value of type `ReportErr`, and uses it to wrap an error of type `(ReportErr, E)` diff --git a/module/core/former_meta/src/derive_former.rs b/module/core/former_meta/src/derive_former.rs index 4a4515c199..e8a166e3d6 100644 --- a/module/core/former_meta/src/derive_former.rs +++ b/module/core/former_meta/src/derive_former.rs @@ -111,7 +111,6 @@ item : {item}"#, /// /// Generate documentation for the former. /// - fn doc_generate( item : &syn::Ident ) -> ( String, String ) { diff --git a/module/core/former_meta/src/derive_former/field.rs b/module/core/former_meta/src/derive_former/field.rs index 98edaccf49..c5b398f7cf 100644 --- a/module/core/former_meta/src/derive_former/field.rs +++ b/module/core/former_meta/src/derive_former/field.rs @@ -5,7 +5,6 @@ use macro_tools::{ container_kind }; /// /// Definition of a field. /// - #[ allow( dead_code ) ] pub struct FormerField< 'a > { @@ -44,7 +43,6 @@ impl< 'a > FormerField< 'a > `scalar_setter_required` */ - /// Construct former field from [`syn::Field`] pub fn from_syn( field : &'a syn::Field, for_storage : bool, for_formed : bool ) -> Result< Self > { @@ -86,7 +84,6 @@ impl< 'a > FormerField< 'a > /// int_optional_1 : core::option::Option::None, /// ``` /// - #[ inline( always ) ] pub fn storage_fields_none( &self ) -> TokenStream { @@ -114,7 +111,6 @@ impl< 'a > FormerField< 'a > /// pub string_optional_1 : core::option::Option< String >, /// ``` /// - #[ inline( always ) ] pub fn storage_field_optional( &self ) -> TokenStream { @@ -171,7 +167,6 @@ impl< 'a > FormerField< 'a > /// }; /// ``` /// - #[ inline( always ) ] #[ allow( clippy::unnecessary_wraps ) ] pub fn storage_field_preform( &self ) -> Result< TokenStream > @@ -289,7 +284,6 @@ impl< 'a > FormerField< 'a > /// /// Extract name of a field out. /// - #[ inline( always ) ] pub fn storage_field_name( &self ) -> TokenStream { @@ -326,7 +320,6 @@ impl< 'a > FormerField< 'a > /// - **Subform Setters**: Generated for fields annotated as subforms, allowing for nested /// forming processes where a field itself can be formed using a dedicated former. /// - #[ inline ] #[ allow( clippy::too_many_arguments ) ] pub fn former_field_setter @@ -441,7 +434,6 @@ impl< 'a > FormerField< 'a > /// self /// } /// ``` - #[ inline ] #[ allow( clippy::format_in_format_args ) ] pub fn scalar_setter @@ -521,7 +513,6 @@ field : {field_ident}"#, /// /// See `tests/inc/former_tests/subform_collection_manual.rs` for example of generated code. /// - #[ inline ] #[ allow( clippy::too_many_lines, clippy::too_many_arguments ) ] pub fn subform_collection_setter @@ -855,7 +846,6 @@ with the new content generated during the subforming process. /// /// See `tests/inc/former_tests/subform_entry_manual.rs` for example of generated code. /// - #[ inline ] #[ allow( clippy::format_in_format_args, clippy::too_many_lines, clippy::too_many_arguments ) ] pub fn subform_entry_setter @@ -1146,7 +1136,6 @@ formation process of the `{item}`. /// Generates setter functions to subform scalar and all corresponding helpers. /// /// See `tests/inc/former_tests/subform_scalar_manual.rs` for example of generated code. - #[ inline ] #[ allow( clippy::format_in_format_args, clippy::unnecessary_wraps, clippy::too_many_lines, clippy::too_many_arguments ) ] pub fn subform_scalar_setter diff --git a/module/core/former_meta/src/derive_former/struct_attrs.rs b/module/core/former_meta/src/derive_former/struct_attrs.rs index f62fff702f..3d01240657 100644 --- a/module/core/former_meta/src/derive_former/struct_attrs.rs +++ b/module/core/former_meta/src/derive_former/struct_attrs.rs @@ -142,7 +142,6 @@ impl ItemAttributes /// This function provides an iterator that yields `syn::Field` objects. If `storage_fields` is set, /// it clones and iterates over its fields. If `storage_fields` is `None`, it returns an empty iterator. /// - // pub fn storage_fields( &self ) -> impl Iterator< Item = syn::Field > pub fn storage_fields( &self ) -> &syn::punctuated::Punctuated< syn::Field, syn::token::Comma > { diff --git a/module/core/former_meta/src/lib.rs b/module/core/former_meta/src/lib.rs index e1fdae8504..0f58850305 100644 --- a/module/core/former_meta/src/lib.rs +++ b/module/core/former_meta/src/lib.rs @@ -93,7 +93,6 @@ mod component /// ``` /// /// This pattern enables fluent and customizable construction of `UserProfile` instances, allowing for easy setting and modification of its fields. - #[ cfg( feature = "enabled" ) ] #[ cfg( feature = "derive_former" ) ] #[ diff --git a/module/core/former_types/src/collection.rs b/module/core/former_types/src/collection.rs index 8df9c34554..767d86aa6a 100644 --- a/module/core/former_types/src/collection.rs +++ b/module/core/former_types/src/collection.rs @@ -48,7 +48,6 @@ mod private /// It is especially crucial in complex data structures, such as `HashMap`s, where entries /// often involve a key-value pair, and simple values need to be restructured to fit this model /// for operations like insertion or update. - pub trait CollectionValToEntry< Val > { /// The specific type of entry that corresponds to the value within the collection. @@ -142,7 +141,6 @@ mod private /// such as `HashMap`s. It not only identifies what constitutes an entry and a value in the context of the collection /// but also provides utility for converting between these two, which is critical in operations involving entry manipulation /// and value retrieval. - pub trait Collection { /// The type of entries that can be added to the collection. This type can differ from `Val` in collections like `HashMap`, diff --git a/module/core/former_types/src/collection/binary_heap.rs b/module/core/former_types/src/collection/binary_heap.rs index 86d350d967..027607fd01 100644 --- a/module/core/former_types/src/collection/binary_heap.rs +++ b/module/core/former_types/src/collection/binary_heap.rs @@ -217,7 +217,6 @@ where /// It is particularly useful in scenarios where binary heaps are repeatedly used or configured in similar ways across different /// parts of an application. /// - pub type BinaryHeapFormer< E, Context, Formed, End > = CollectionFormer::< E, BinaryHeapDefinition< E, Context, Formed, End > >; diff --git a/module/core/former_types/src/collection/btree_map.rs b/module/core/former_types/src/collection/btree_map.rs index 9f3d01e698..fcf7db6879 100644 --- a/module/core/former_types/src/collection/btree_map.rs +++ b/module/core/former_types/src/collection/btree_map.rs @@ -212,7 +212,6 @@ where /// /// The alias helps reduce boilerplate code and enhances readability, making the construction of hash maps in /// a builder pattern both efficient and expressive. - pub type BTreeMapFormer< K, E, Context, Formed, End > = CollectionFormer::< ( K, E ), BTreeMapDefinition< K, E, Context, Formed, End > >; @@ -225,7 +224,6 @@ CollectionFormer::< ( K, E ), BTreeMapDefinition< K, E, Context, Formed, End > > /// with the builder pattern provided by the `former` framework. It's a convenience trait that simplifies /// creating configured hash map builders with default settings. /// - pub trait BTreeMapExt< K, E > : sealed::Sealed where K : Ord, diff --git a/module/core/former_types/src/collection/btree_set.rs b/module/core/former_types/src/collection/btree_set.rs index d09e1793d6..42aeaf9adb 100644 --- a/module/core/former_types/src/collection/btree_set.rs +++ b/module/core/former_types/src/collection/btree_set.rs @@ -205,7 +205,6 @@ for BTreeSet< E > /// It is particularly useful in scenarios where binary tree sets are repeatedly used or configured in similar ways across different /// parts of an application. /// - pub type BTreeSetFormer< E, Context, Formed, End > = CollectionFormer::< E, BTreeSetDefinition< E, Context, Formed, End > >; diff --git a/module/core/former_types/src/collection/hash_map.rs b/module/core/former_types/src/collection/hash_map.rs index 1c4444fa4a..c204bcd361 100644 --- a/module/core/former_types/src/collection/hash_map.rs +++ b/module/core/former_types/src/collection/hash_map.rs @@ -222,7 +222,6 @@ where /// /// The alias helps reduce boilerplate code and enhances readability, making the construction of hash maps in /// a builder pattern both efficient and expressive. - pub type HashMapFormer< K, E, Context, Formed, End > = CollectionFormer::< ( K, E ), HashMapDefinition< K, E, Context, Formed, End > >; @@ -235,7 +234,6 @@ CollectionFormer::< ( K, E ), HashMapDefinition< K, E, Context, Formed, End > >; /// with the builder pattern provided by the `former` framework. It's a convenience trait that simplifies /// creating configured hash map builders with default settings. /// - pub trait HashMapExt< K, E > : sealed::Sealed where K : ::core::cmp::Eq + ::core::hash::Hash, diff --git a/module/core/former_types/src/collection/hash_set.rs b/module/core/former_types/src/collection/hash_set.rs index 97d7ddd66e..38228296db 100644 --- a/module/core/former_types/src/collection/hash_set.rs +++ b/module/core/former_types/src/collection/hash_set.rs @@ -249,7 +249,6 @@ where /// the `CollectionFormer` with predefined settings. This approach minimizes boilerplate code and enhances /// readability, making it ideal for fluent and expressive construction of set collections within custom data structures. /// - pub type HashSetFormer< K, Context, Formed, End > = CollectionFormer::< K, HashSetDefinition< K, Context, Formed, End > >; @@ -261,7 +260,6 @@ CollectionFormer::< K, HashSetDefinition< K, Context, Formed, End > >; /// set construction. It simplifies the process of building `HashSet` instances by providing a straightforward /// way to start the builder pattern with default context and termination behavior. /// - pub trait HashSetExt< K > : sealed::Sealed where K : ::core::cmp::Eq + ::core::hash::Hash, diff --git a/module/core/former_types/src/collection/linked_list.rs b/module/core/former_types/src/collection/linked_list.rs index 1ace9637a9..07b0c80674 100644 --- a/module/core/former_types/src/collection/linked_list.rs +++ b/module/core/former_types/src/collection/linked_list.rs @@ -200,7 +200,6 @@ for LinkedList< E > /// It is particularly useful in scenarios where lists are repeatedly used or configured in similar ways across different /// parts of an application. /// - pub type LinkedListFormer< E, Context, Formed, End > = CollectionFormer::< E, LinkedListDefinition< E, Context, Formed, End > >; diff --git a/module/core/former_types/src/collection/vector.rs b/module/core/former_types/src/collection/vector.rs index 5e88250511..0cef9fabfd 100644 --- a/module/core/former_types/src/collection/vector.rs +++ b/module/core/former_types/src/collection/vector.rs @@ -200,7 +200,6 @@ for Vec< E > /// It is particularly useful in scenarios where vectors are repeatedly used or configured in similar ways across different /// parts of an application. /// - pub type VectorFormer< E, Context, Formed, End > = CollectionFormer::< E, VectorDefinition< E, Context, Formed, End > >; diff --git a/module/core/former_types/src/collection/vector_deque.rs b/module/core/former_types/src/collection/vector_deque.rs index ae207c612e..72203567ed 100644 --- a/module/core/former_types/src/collection/vector_deque.rs +++ b/module/core/former_types/src/collection/vector_deque.rs @@ -200,7 +200,6 @@ for VecDeque< E > /// It is particularly useful in scenarios where vector deques are repeatedly used or configured in similar ways across different /// parts of an application. /// - pub type VecDequeFormer< E, Context, Formed, End > = CollectionFormer::< E, VecDequeDefinition< E, Context, Formed, End > >; diff --git a/module/core/former_types/src/forming.rs b/module/core/former_types/src/forming.rs index 46c9b87aff..72feac9fb4 100644 --- a/module/core/former_types/src/forming.rs +++ b/module/core/former_types/src/forming.rs @@ -26,7 +26,6 @@ /// - Storage-specific fields which are not present in formed structure. /// /// Look example `former_custom_mutator.rs` - pub trait FormerMutator where Self : crate::FormerDefinitionTypes, @@ -59,7 +58,6 @@ where /// # Parameters /// - `Storage`: The type of the collection being processed. /// - `Context`: The type of the context that might be altered or returned upon completion. - pub trait FormingEnd< Definition : crate::FormerDefinitionTypes > { /// Called at the end of the subforming process to return the modified or original context. @@ -251,7 +249,6 @@ for FormingEndClosure< Definition > /// are aligned from the onset, particularly when one former is nested within another, facilitating the creation /// of complex hierarchical data structures. /// - pub trait FormerBegin< Definition : > where Definition : crate::FormerDefinition, diff --git a/module/core/interval_adapter/src/lib.rs b/module/core/interval_adapter/src/lib.rs index 19fb7c2537..6bf7fb7c55 100644 --- a/module/core/interval_adapter/src/lib.rs +++ b/module/core/interval_adapter/src/lib.rs @@ -155,7 +155,6 @@ mod private /// `NonIterableInterval` it does not implement iterator unlike `IterableInterval`. /// `IterableInterval` inherits all methods of `NonIterableInterval`. /// - pub trait IterableInterval< T = isize > where Self : IntoIterator< Item = T > + NonIterableInterval< T >, @@ -179,7 +178,6 @@ mod private /// /// Both [`core::ops::Range`], [`core::ops::RangeInclusive`] are convertable to [`crate::Interval`] /// - #[ allow( clippy::used_underscore_binding ) ] #[ derive( PartialEq, Eq, Debug, Clone, Copy ) ] pub struct Interval< T = isize > diff --git a/module/core/iter_tools/src/iter.rs b/module/core/iter_tools/src/iter.rs index 62b0294989..4c6a69b7a1 100644 --- a/module/core/iter_tools/src/iter.rs +++ b/module/core/iter_tools/src/iter.rs @@ -60,7 +60,6 @@ mod private /// } /// /// ``` - #[ cfg( feature = "iter_trait" ) ] pub trait _IterTrait< 'a, T > where diff --git a/module/core/macro_tools/src/attr.rs b/module/core/macro_tools/src/attr.rs index e2edde225f..c600416f38 100644 --- a/module/core/macro_tools/src/attr.rs +++ b/module/core/macro_tools/src/attr.rs @@ -51,7 +51,6 @@ mod private /// ``` /// # Errors /// qqq: doc - pub fn has_debug< 'a >( attrs : impl Iterator< Item = &'a syn::Attribute > ) -> syn::Result< bool > { for attr in attrs diff --git a/module/core/macro_tools/src/container_kind.rs b/module/core/macro_tools/src/container_kind.rs index a2e1de1297..73423dc5de 100644 --- a/module/core/macro_tools/src/container_kind.rs +++ b/module/core/macro_tools/src/container_kind.rs @@ -80,7 +80,6 @@ mod private /// ``` /// # Panics /// qqq: doc - #[ must_use ] pub fn of_optional( ty : &syn::Type ) -> ( ContainerKind, bool ) { diff --git a/module/core/macro_tools/src/derive.rs b/module/core/macro_tools/src/derive.rs index 7dd8888d61..7e754d34d9 100644 --- a/module/core/macro_tools/src/derive.rs +++ b/module/core/macro_tools/src/derive.rs @@ -27,7 +27,6 @@ mod private /// ``` /// # Errors /// qqq: doc - pub fn named_fields( ast : &syn::DeriveInput ) -> crate::Result< &Punctuated< syn::Field, syn::token::Comma > > { diff --git a/module/core/macro_tools/src/diag.rs b/module/core/macro_tools/src/diag.rs index 40a3afb1bf..1a183908ea 100644 --- a/module/core/macro_tools/src/diag.rs +++ b/module/core/macro_tools/src/diag.rs @@ -45,7 +45,6 @@ mod private /// and a semicolon at the end of each line. The function also demonstrates handling /// of input strings that end with a newline character by appending an additional line /// consisting only of the prefix and postfix. - pub fn indentation< Prefix, Src, Postfix >( prefix : Prefix, src : Src, postfix : Postfix ) -> String where Prefix : AsRef< str >, @@ -133,7 +132,6 @@ mod private /// println!( "{}", formatted_report ); /// ``` /// - #[ allow( clippy::needless_pass_by_value ) ] pub fn report_format< IntoAbout, IntoInput, IntoOutput > ( @@ -196,7 +194,6 @@ mod private /// The above example demonstrates how the `report_print` function can be used to visualize the changes from original input code to the generated code, /// helping developers to verify and understand the modifications made during code generation processes. The output is formatted to show clear distinctions /// between the 'original' and 'generated' sections, providing an easy-to-follow comparison. - pub fn report_print< IntoAbout, IntoInput, IntoOutput > ( about : IntoAbout, input : IntoInput, output : IntoOutput @@ -221,7 +218,6 @@ mod private /// tree_print!( tree_type ); /// ``` /// - #[ macro_export ] macro_rules! tree_print { @@ -249,7 +245,6 @@ mod private /// tree_print!( tree_type ); /// ``` /// - #[ macro_export ] macro_rules! code_print { @@ -268,7 +263,6 @@ mod private /// /// Macro for diagnostics purpose to export both syntax tree and source code behind it into a string. /// - #[ macro_export ] macro_rules! tree_diagnostics_str { @@ -282,7 +276,6 @@ mod private /// /// Macro for diagnostics purpose to diagnose source code behind it and export it into a string. /// - #[ macro_export ] macro_rules! code_diagnostics_str { @@ -296,7 +289,6 @@ mod private /// /// Macro to export source code behind a syntax tree into a string. /// - #[ macro_export ] macro_rules! code_to_str { @@ -317,7 +309,6 @@ mod private /// # () /// ``` /// - #[ macro_export ] macro_rules! syn_err { @@ -355,7 +346,6 @@ mod private /// # () /// ``` /// - #[ macro_export ] macro_rules! return_syn_err { diff --git a/module/core/macro_tools/src/generic_params.rs b/module/core/macro_tools/src/generic_params.rs index 401fd0d326..b54e5787b9 100644 --- a/module/core/macro_tools/src/generic_params.rs +++ b/module/core/macro_tools/src/generic_params.rs @@ -133,7 +133,6 @@ mod private /// }; /// /// `assert_eq`!( got, exp ); - #[ must_use ] #[ allow( clippy::default_trait_access ) ] pub fn merge( a : &syn::Generics, b : &syn::Generics ) -> syn::Generics @@ -210,7 +209,6 @@ mod private /// assert_eq!( simplified_generics.params.len(), 4 ); // Contains T, U, 'a, and N /// assert!( simplified_generics.where_clause.is_none() ); // Where clause is removed /// ``` - #[ allow( clippy::default_trait_access ) ] #[ must_use ] pub fn only_names( generics : &syn::Generics ) -> syn::Generics @@ -395,7 +393,6 @@ mod private /// } /// ``` /// - #[ allow( clippy::type_complexity ) ] #[ must_use ] pub fn decompose diff --git a/module/core/macro_tools/src/lib.rs b/module/core/macro_tools/src/lib.rs index c3a663cf22..eed453737b 100644 --- a/module/core/macro_tools/src/lib.rs +++ b/module/core/macro_tools/src/lib.rs @@ -14,7 +14,6 @@ mod private /// /// Result with `syn::Error`. /// - pub type Result< T > = core::result::Result< T, syn::Error >; } @@ -70,7 +69,6 @@ pub mod iter; /// /// Dependencies of the module. /// - #[ cfg( feature = "enabled" ) ] #[ allow( unused_imports ) ] pub mod dependency diff --git a/module/core/macro_tools/src/name.rs b/module/core/macro_tools/src/name.rs index ae70cba3f8..c6899b308a 100644 --- a/module/core/macro_tools/src/name.rs +++ b/module/core/macro_tools/src/name.rs @@ -9,7 +9,6 @@ mod private /// /// Trait to get name of an syntax element. /// - pub trait Name { /// Get name. diff --git a/module/core/macro_tools/src/quantifier.rs b/module/core/macro_tools/src/quantifier.rs index 030074314a..c3c1e2607b 100644 --- a/module/core/macro_tools/src/quantifier.rs +++ b/module/core/macro_tools/src/quantifier.rs @@ -11,7 +11,6 @@ mod private /// /// Marker saying how to parse several elements of such type in a row. /// - pub trait AsMuchAsPossibleNoDelimiter {} /// Element of parsing. diff --git a/module/core/macro_tools/src/struct_like.rs b/module/core/macro_tools/src/struct_like.rs index 321fbffee3..abed28a510 100644 --- a/module/core/macro_tools/src/struct_like.rs +++ b/module/core/macro_tools/src/struct_like.rs @@ -18,7 +18,7 @@ mod private Variant( &'a syn::Variant ), } - impl< 'a > Copy for FieldOrVariant< 'a > + impl Copy for FieldOrVariant< '_ > { } @@ -56,7 +56,7 @@ mod private } } - impl< 'a > FieldOrVariant< 'a > + impl FieldOrVariant< '_ > { /// Returns a reference to the attributes of the item. diff --git a/module/core/mod_interface/src/lib.rs b/module/core/mod_interface/src/lib.rs index 07820b8983..193b9197c1 100644 --- a/module/core/mod_interface/src/lib.rs +++ b/module/core/mod_interface/src/lib.rs @@ -56,7 +56,6 @@ pub mod exposed } /// Prelude to use essentials: `use my_module::prelude::*`. - #[ cfg( feature = "enabled" ) ] #[ allow( unused_imports ) ] pub mod prelude diff --git a/module/core/mod_interface_meta/src/impls.rs b/module/core/mod_interface_meta/src/impls.rs index cdac53e906..0d80eb7af4 100644 --- a/module/core/mod_interface_meta/src/impls.rs +++ b/module/core/mod_interface_meta/src/impls.rs @@ -285,7 +285,6 @@ mod private /// /// Handle record micro module. /// - fn record_micro_module ( record : &Record, diff --git a/module/core/mod_interface_meta/src/lib.rs b/module/core/mod_interface_meta/src/lib.rs index f077e63508..fe22c8b29c 100644 --- a/module/core/mod_interface_meta/src/lib.rs +++ b/module/core/mod_interface_meta/src/lib.rs @@ -105,7 +105,6 @@ use use_tree::exposed::*; /// /// Protocol of modularity unifying interface of a module and introducing layers. /// - #[ cfg( feature = "enabled" ) ] #[ proc_macro ] pub fn mod_interface( input : proc_macro::TokenStream ) -> proc_macro::TokenStream diff --git a/module/core/mod_interface_meta/src/record.rs b/module/core/mod_interface_meta/src/record.rs index 24b773be10..8aa78aeb17 100644 --- a/module/core/mod_interface_meta/src/record.rs +++ b/module/core/mod_interface_meta/src/record.rs @@ -9,7 +9,6 @@ mod private /// /// Custom keywords. /// - pub mod kw { super::syn::custom_keyword!( layer ); @@ -174,7 +173,6 @@ mod private /// /// Many records. /// - pub type Records = Many< Record >; impl AsMuchAsPossibleNoDelimiter for Record {} diff --git a/module/core/mod_interface_meta/src/visibility.rs b/module/core/mod_interface_meta/src/visibility.rs index 747b2a2da5..770c0f5e04 100644 --- a/module/core/mod_interface_meta/src/visibility.rs +++ b/module/core/mod_interface_meta/src/visibility.rs @@ -10,7 +10,6 @@ mod private /// /// Custom keywords /// - pub mod kw { #[ allow( clippy::wildcard_imports ) ] @@ -28,7 +27,6 @@ mod private /// /// Visibility constructor. /// - pub trait VisibilityInterface { type Token : syn::token::Token + syn::parse::Parse; @@ -41,7 +39,6 @@ mod private /// /// Trait answering question can the visibility be used for non-standard module. /// - pub trait ValidSubNamespace { fn valid_sub_namespace( &self ) -> bool { false } diff --git a/module/move/wca/benches/bench.rs b/module/move/wca/benches/bench.rs index a1dfbf1b0e..45469b2476 100644 --- a/module/move/wca/benches/bench.rs +++ b/module/move/wca/benches/bench.rs @@ -1,14 +1,17 @@ #![ allow( missing_debug_implementations ) ] #![ allow( missing_docs ) ] -use std::collections::HashMap; + use criterion::{ criterion_group, criterion_main, Criterion }; -use wca::{ CommandsAggregator, Routine, Type }; +use wca::grammar::Dictionary; +use wca::{ CommandsAggregator, Type }; + -fn init( count : usize, command : wca::Command ) -> CommandsAggregator + +fn init( count : usize, command : wca::grammar::Command ) -> CommandsAggregator { - let mut commands = Vec::with_capacity( count ); - let mut routines = HashMap::with_capacity( count ); + + let mut dic_former = Dictionary::former(); for i in 0 .. count { let name = format!( "command_{i}" ); @@ -16,19 +19,15 @@ fn init( count : usize, command : wca::Command ) -> CommandsAggregator let mut command = command.clone(); command.phrase = name.clone(); - commands.push( command ); - routines.insert - ( - name, Routine::new( | _ | { assert_eq!( 1 + 1, 2 ); Ok( () ) } ), - ); + dic_former = dic_former.command( command ); + } - - assert_eq!( count, commands.len() ); - assert_eq!( count, routines.len() ); - + let dictionary = dic_former.form(); + + // The CommandsAggregator has changed and there are no more grammar fields and the executor no longer stores routines. + // Accordingly, I made changes and write commands through DictionaryFormer and pass it to CommandsAggregator CommandsAggregator::former() - .grammar( commands ) - .executor( routines ) + .dictionary( dictionary ) .perform() } @@ -37,7 +36,7 @@ fn initialize_commands_without_args( count : usize ) -> CommandsAggregator init ( count, - wca::Command::former() + wca::grammar::Command::former() .hint( "hint" ) .long_hint( "long_hint" ) .phrase( "{placeholder}" ) @@ -45,35 +44,39 @@ fn initialize_commands_without_args( count : usize ) -> CommandsAggregator ) } -fn initialize_commands_with_subjects( count : usize ) -> CommandsAggregator { +fn initialize_commands_with_subjects( count : usize ) -> CommandsAggregator +{ + // The way commands are initialized has changed, now the ComandFormer from the grammar module is used and the subject() and property methods are called differently init ( count, - wca::Command::former() + wca::grammar::Command::former() .hint( "hint" ) .long_hint( "long_hint" ) .phrase( "{placeholder}" ) - .subject( "hint", Type::String, true ) - .subject( "hint", Type::String, true ) + .subject().hint( "hint" ).kind( Type::String ).optional( true ).end() + .subject().hint( "hint" ).kind( Type::String ).optional( true ).end() .form(), ) } -fn initialize_commands_with_properties( count : usize ) -> CommandsAggregator { +fn initialize_commands_with_properties( count : usize ) -> CommandsAggregator +{ init ( count, - wca::Command::former() + wca::grammar::Command::former() .hint( "hint" ) .long_hint( "long_hint" ) .phrase( "{placeholder}" ) - .property( "prop", "hint", Type::String, true ) - .property( "prop2", "hint", Type::String, true ) + .property( "prop" ).hint( "hint" ).kind( Type::String ).optional( true ).end() + .property( "prop2" ).hint( "hint" ).kind( Type::String ).optional( true ).end() .form(), ) } -fn run_commands< S : AsRef< str > >( ca : CommandsAggregator, command : S ) { +fn run_commands< S : AsRef< str > >( ca : CommandsAggregator, command : S ) +{ ca.perform( command.as_ref() ).unwrap() } diff --git a/module/move/wca/examples/wca_custom_error.rs b/module/move/wca/examples/wca_custom_error.rs index 47fef16985..7b3862b77c 100644 --- a/module/move/wca/examples/wca_custom_error.rs +++ b/module/move/wca/examples/wca_custom_error.rs @@ -1,5 +1,5 @@ //! -//! # Handling Errors with CommandsAggregator +//! # Handling Errors with `CommandsAggregator` //! //! This module provides an example of how to use `wca::CommandsAggregator` to manage error handling in a command-line interface. The `CommandsAggregator` offers a fluent interface for defining commands and associating them with various error types, making it straightforward to handle and present errors in a structured way. //! @@ -19,20 +19,20 @@ fn main() -> error_tools::error::untyped::Result< () > { let ca = wca::CommandsAggregator::former() .command( "error.string" ) - .hint( "Returns error as a string" ) - .routine( || { Err( "this is string error" ) } ) + .hint( "Returns error as a string" ) + .routine( || { Err( "this is string error" ) } ) .end() .command( "error.typed" ) - .hint( "Returns error as a custom error" ) - .routine( || { Err( CustomError::TheError ) } ) + .hint( "Returns error as a custom error" ) + .routine( || { Err( CustomError::TheError ) } ) .end() .command( "error.untyped" ) - .hint( "Returns error as untyped error" ) - .routine( || { Err( error_tools::error::untyped::format_err!( "this is untyped error" ) ) } ) + .hint( "Returns error as untyped error" ) + .routine( || { Err( error_tools::error::untyped::format_err!( "this is untyped error" ) ) } ) .end() .command( "error.with_context" ) - .hint( "Returns error as untyped error with context" ) - .routine( || { Err( error_tools::error::untyped::format_err!( "this is untyped error" ).context( "with context" ) ) } ) + .hint( "Returns error as untyped error with context" ) + .routine( || { Err( error_tools::error::untyped::format_err!( "this is untyped error" ).context( "with context" ) ) } ) .end() .perform(); diff --git a/module/move/wca/examples/wca_fluent.rs b/module/move/wca/examples/wca_fluent.rs index 3d5475a481..6b2f4adf61 100644 --- a/module/move/wca/examples/wca_fluent.rs +++ b/module/move/wca/examples/wca_fluent.rs @@ -16,33 +16,40 @@ fn main() -> error_tools::error::untyped::Result< () > let ca = wca::CommandsAggregator::former() .with_context( Mutex::new( 0 ) ) .command( "echo" ) - .hint( "prints all subjects and properties" ) - .subject().kind( Type::String ).optional( true ).end() - .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ) } ) - .end() + .hint( "prints all subjects and properties" ) + .subject().kind( Type::String ).optional( true ).end() + .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | + { + println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ) + }) + .end() .command( "inc" ) - .hint( "This command increments a state number each time it is called consecutively. (E.g. `.inc .inc`)" ) - .routine( | ctx : Context | - { - let i : Arc< Mutex< i32 > > = ctx.get().unwrap(); - let mut i = i.lock().unwrap(); - println!( "i = {}", i ); - *i += 1; - } ) - .end() + .hint( "This command increments a state number each time it is called consecutively. (E.g. `.inc .inc`)" ) + .routine( | ctx : Context | + { + let i : Arc< Mutex< i32 > > = ctx.get().unwrap(); + let mut i = i.lock().unwrap(); + println!( "i = {}", i ); + *i += 1; + }) + .end() .command( "error" ) - .hint( "prints all subjects and properties" ) - .subject().kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!( "Returns an error" ); Err( format!( "{}", o.args.get_owned::< String >( 0 ).unwrap_or_default() ) ) } ) - .end() + .hint( "prints all subjects and properties" ) + .subject().kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | + { + println!( "Returns an error" ); + Err( format!( "{}", o.args.get_owned::< String >( 0 ).unwrap_or_default() ) ) + }) + .end() .command( "exit" ) - .hint( "just exit" ) - .routine( Handler::< _, std::convert::Infallible >::from - ( - || { println!( "exit" ); std::process::exit( 0 ) } - ) ) - .end() + .hint( "just exit" ) + .routine( Handler::< _, std::convert::Infallible >::from( || + { + println!( "exit" ); std::process::exit( 0 ) + })) + .end() .perform(); let args: Vec< String > = std::env::args().skip( 1 ).collect(); diff --git a/module/move/wca/examples/wca_suggest.rs b/module/move/wca/examples/wca_suggest.rs index b9b54989a8..f57c589de6 100644 --- a/module/move/wca/examples/wca_suggest.rs +++ b/module/move/wca/examples/wca_suggest.rs @@ -27,13 +27,13 @@ fn main() -> error_tools::error::untyped::Result< () > let ca = CommandsAggregator::former() .command( "echo" ) - .hint( "prints all subjects and properties" ) - .subject().kind( Type::String ).optional( true ).end() - .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | - { - println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ); - }) + .hint( "prints all subjects and properties" ) + .subject().kind( Type::String ).optional( true ).end() + .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | + { + println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ); + }) .end() .perform(); diff --git a/module/move/wca/examples/wca_trivial.rs b/module/move/wca/examples/wca_trivial.rs index 1df6dec815..443742cc49 100644 --- a/module/move/wca/examples/wca_trivial.rs +++ b/module/move/wca/examples/wca_trivial.rs @@ -20,18 +20,18 @@ fn main() -> error_tools::error::untyped::Result< () > { let ca = CommandsAggregator::former() .command( "exit" ) - .hint( "just exit" ) - .routine( || exit() ) - .end() + .hint( "just exit" ) + // fix clippy + .routine( exit ) + .end() .command( "echo" ) - .hint( "prints all subjects and properties" ) - .subject().hint( "Subject" ).kind( Type::String ).optional( true ).end() - .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() - .routine( f1 ) - .end() + .hint( "prints all subjects and properties" ) + .subject().hint( "Subject" ).kind( Type::String ).optional( true ).end() + .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() + .routine( f1 ) + .end() .order( Order::Lexicography ) - .perform() - ; + .perform(); // aaa : aaa2 : for Bohdan : that should work // let ca = wca::CommandsAggregator::former() diff --git a/module/move/wca/src/ca/aggregator.rs b/module/move/wca/src/ca/aggregator.rs index fb3725ba16..8c46b6c1c2 100644 --- a/module/move/wca/src/ca/aggregator.rs +++ b/module/move/wca/src/ca/aggregator.rs @@ -30,7 +30,8 @@ mod private { // Result, untyped::Error as wError, // xxx - for_lib::*, + // only importing Error from this module is used + for_lib::Error, }; use iter_tools::Itertools; @@ -149,7 +150,7 @@ mod private dictionary.order = ca.order.unwrap_or_default(); let help_generator = core::mem::take( &mut ca.help_generator ).unwrap_or_default(); - let help_variants = core::mem::take( &mut ca.help_variants ).unwrap_or_else( || HashSet::from([ HelpVariants::All ]) ); + let help_variants = core::mem::take( &mut ca.help_variants ).unwrap_or_else( || HashSet::from( [ HelpVariants::All ] ) ); if help_variants.contains( &HelpVariants::All ) { @@ -286,8 +287,14 @@ mod private { let Input( ref program ) = program.into_input(); - let raw_program = self.parser.parse( program ).map_err( | e | Error::Validation( ValidationError::Parser { input : format!( "{program:?}" ), error : e } ) )?; - let grammar_program = self.verifier.to_program( &self.dictionary, raw_program ).map_err( | e | Error::Validation( ValidationError::Verifier( e ) ) )?; + let raw_program = self.parser.parse( program ).map_err( | e | + { + Error::Validation( ValidationError::Parser { input : format!( "{program:?}" ), error : e } ) + })?; + let grammar_program = self.verifier.to_program( &self.dictionary, raw_program ).map_err( | e | + { + Error::Validation( ValidationError::Verifier( e ) ) + })?; if let Some( callback ) = &self.callback_fn { diff --git a/module/move/wca/src/ca/executor/context.rs b/module/move/wca/src/ca/executor/context.rs index a9611b618e..4189550df5 100644 --- a/module/move/wca/src/ca/executor/context.rs +++ b/module/move/wca/src/ca/executor/context.rs @@ -56,7 +56,6 @@ mod private /// # Arguments /// /// * `value` - The value to be stored in the `Context`. The value must implement the `Send` and `Sync` traits. - /// ``` // `'static` means that the object must be owned or live at least as a `Context' pub fn new< T : Send + Sync + 'static >( value : T ) -> Self { diff --git a/module/move/wca/src/ca/executor/executor.rs b/module/move/wca/src/ca/executor/executor.rs index d6a7a3bdf1..f76cf5e4ab 100644 --- a/module/move/wca/src/ca/executor/executor.rs +++ b/module/move/wca/src/ca/executor/executor.rs @@ -2,7 +2,6 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - use ca::help::{ HelpGeneratorOptions, generate_help_content, LevelOfDetail }; use verifier::VerifiedCommand; use parser::Program; @@ -51,7 +50,7 @@ mod private // aaa : use typed error // aaa : done pub fn program( &self, dictionary : &Dictionary, program : Program< VerifiedCommand > ) - -> Result< (), CommandError > + -> Result< (), Box< CommandError > > { for command in program.commands { @@ -80,18 +79,19 @@ mod private // aaa : use typed error // aaa : done pub fn command( &self, dictionary : &Dictionary, command : VerifiedCommand ) - -> Result< (), CommandError > + // fix clippy error + -> Result< (), Box< CommandError > > { if command.internal_command { - _exec_internal_command( dictionary, command.clone() ) - .map_err( | error | CommandError::Internal { command, error } ) + exec_internal_command( dictionary, command.clone() ) + .map_err( | error | Box::new( CommandError::Internal { command, error } ) ) } else { let routine = dictionary.command( &command.phrase ).unwrap().routine.clone(); - _exec_command( command.clone(), routine, self.context.clone() ) - .map_err( | error | CommandError::User { command, error } ) + exec_command( command.clone(), routine, self.context.clone() ) + .map_err( | error | Box::new( CommandError::User { command, error } ) ) } } @@ -101,7 +101,8 @@ mod private // qqq : use typed error // aaa : should it be typed? it is user command with unknown error type - fn _exec_command( command : VerifiedCommand, routine : Routine, ctx : Context ) + // fix clippy error + fn exec_command( command : VerifiedCommand, routine : Routine, ctx : Context ) -> error::untyped::Result< () > { match routine @@ -123,7 +124,8 @@ mod private // aaa : use typed error // aaa : done #[ allow( clippy::needless_pass_by_value ) ] - fn _exec_internal_command( dictionary : &Dictionary, command : VerifiedCommand ) + // fix clippy error + fn exec_internal_command( dictionary : &Dictionary, command : VerifiedCommand ) -> Result< (), InternalCommandError > { match command.phrase.as_str() diff --git a/module/move/wca/src/ca/executor/routine.rs b/module/move/wca/src/ca/executor/routine.rs index f40594af22..13d1fd0d8b 100644 --- a/module/move/wca/src/ca/executor/routine.rs +++ b/module/move/wca/src/ca/executor/routine.rs @@ -180,7 +180,6 @@ mod private /// // Do what you need to do /// } /// ) ); - pub struct Handler< I, O >( Box< dyn Fn( I ) -> O > ); impl< I, O > core::fmt::Debug for Handler< I, O > @@ -204,9 +203,9 @@ mod private } impl< F, R > From< F > for Handler< VerifiedCommand, R > - where - R : IntoResult + 'static, - F : Fn( VerifiedCommand ) -> R + 'static, + where + R : IntoResult + 'static, + F : Fn( VerifiedCommand ) -> R + 'static, { fn from( value : F ) -> Self { diff --git a/module/move/wca/src/ca/formatter.rs b/module/move/wca/src/ca/formatter.rs index 1c606532d7..e3cc4d69fe 100644 --- a/module/move/wca/src/ca/formatter.rs +++ b/module/move/wca/src/ca/formatter.rs @@ -32,7 +32,7 @@ mod private { let text = grammar.commands() .into_iter() - .map( |( name, cmd )| + .map( | ( name, cmd ) | { let subjects = cmd.subjects.iter().fold( String::new(), | _, _ | " `[argument]`".to_string() ); let properties = if cmd.properties.is_empty() { " " } else { " `[properties]` " }; @@ -54,14 +54,12 @@ mod private let about_each_command = grammar.commands() .into_iter() - .map( |( name, cmd )| + .map( | ( name, cmd ) | { let subjects = cmd.subjects.iter().fold( String::new(), | _, _ | " `[Subject]`".to_string() ); let properties = if cmd.properties.is_empty() { " " } else { " `[properties]` " }; let hint = if cmd.hint.is_empty() { &cmd.long_hint } else { &cmd.hint }; - let heading = format!( "## .{name}{subjects}{properties}\n__{hint}__\n" ); - let hint = if cmd.long_hint.is_empty() { &cmd.hint } else { &cmd.long_hint }; let full_subjects = cmd .subjects @@ -69,7 +67,7 @@ mod private .enumerate() .map ( - |( number, subj )| + | ( number, subj ) | format!( "\n- {}subject_{number} - {} `[{:?}]`", if subj.optional { "`< optional >` " } else { "" }, subj.hint, subj.kind ) ) .join( "\n" ); @@ -78,7 +76,7 @@ mod private .into_iter() .map ( - |( name, value )| + | ( name, value ) | format!( "\n- {}{} - {} `[{:?}]`", if value.optional { "`< optional >` " } else { "" }, value.hint, name, value.kind ) ) .join( "\n" ); diff --git a/module/move/wca/src/ca/grammar/command.rs b/module/move/wca/src/ca/grammar/command.rs index e1bc974d63..31b4568112 100644 --- a/module/move/wca/src/ca/grammar/command.rs +++ b/module/move/wca/src/ca/grammar/command.rs @@ -110,7 +110,10 @@ mod private // aaa : it is usable /// The type `Routine` represents the specific implementation of the routine. #[ scalar( setter = false ) ] - #[ former( default = Routine::from( Handler::< _, std::convert::Infallible >::from( || { panic!( "No routine available: A handler function for the command is missing" ) } ) ) ) ] + #[ former( default = Routine::from( Handler::< _, std::convert::Infallible >::from( || + { + panic!( "No routine available: A handler function for the command is missing" ) + })))] pub routine : Routine, } @@ -215,7 +218,8 @@ mod private /// * `name` - The name of the property. It should implement the `Into< String >` trait. /// # Panics /// qqq: doc - pub fn property< IntoName >( self, name : IntoName ) -> PropertyDescriptionAsSubformer< Self, impl PropertyDescriptionAsSubformerEnd< Self > > + pub fn property< IntoName >( self, name : IntoName ) + -> PropertyDescriptionAsSubformer< Self, impl PropertyDescriptionAsSubformerEnd< Self > > where IntoName : Into< String >, { diff --git a/module/move/wca/src/ca/grammar/types.rs b/module/move/wca/src/ca/grammar/types.rs index 6bea357228..55bda746fe 100644 --- a/module/move/wca/src/ca/grammar/types.rs +++ b/module/move/wca/src/ca/grammar/types.rs @@ -98,7 +98,7 @@ mod private impl Display for Value { - fn fmt( &self, f : &mut Formatter< '_ >) -> std::fmt::Result + fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { match self { @@ -130,7 +130,7 @@ mod private macro_rules! value_into_impl { - ( $( $value_kind : path => $( $kind : ty => $cast : expr ),+ );+ ) => + ( $( $value_kind : path => $( $kind : ty => $cast : expr ), + ); + ) => { $( $( impl From< Value > for $kind @@ -187,9 +187,18 @@ mod private match self { Self::String => Ok( Value::String( value ) ), - Self::Number => value.parse().map_err( | _ | error::untyped::format_err!( "Can not parse number from `{}`", value ) ).map( Value::Number ), + Self::Number => value.parse().map_err( | _ | + { + error::untyped::format_err!( "Can not parse number from `{}`", value ) + }).map( Value::Number ), Self::Path => Ok( Value::Path( value.into() ) ), - Self::Bool => Ok( Value::Bool( match value.as_str() { "1" | "true" => true, "0" | "false" => false, _ => return Err( error::untyped::format_err!( "Can not parse bool from `{}`", value ) ) } ) ), + Self::Bool => Ok( Value::Bool( match value.as_str() + { + "1" | "true" => true, "0" | "false" => false, _ => + { + return Err( error::untyped::format_err!( "Can not parse bool from `{}`", value ) ) + } + })), Self::List( kind, delimeter ) => { let values: error::untyped::Result< Vec< Value > > = value diff --git a/module/move/wca/src/ca/help.rs b/module/move/wca/src/ca/help.rs index b48a8ed93c..85e87dab75 100644 --- a/module/move/wca/src/ca/help.rs +++ b/module/move/wca/src/ca/help.rs @@ -50,13 +50,13 @@ mod private /// Reresents how much information to display for the subjects /// /// - `None` - nothing - /// - `Simple` - + /// - `Simple` - < subjects > /// - `Detailed` - each subject with information about it. E.g. `` pub subject_detailing : LevelOfDetail, /// Reresents how much information to display for the properties /// /// - `None` - nothing - /// - `Simple` - + /// - `Simple` - < properties > /// - `Detailed` - each property with information about it. E.g. `` pub property_detailing : LevelOfDetail, /// Reresents how much information to display for the properties @@ -110,20 +110,32 @@ mod private LevelOfDetail::None => String::new(), _ if command.subjects.is_empty() => String::new(), LevelOfDetail::Simple => "< subjects >".into(), - LevelOfDetail::Detailed => command.subjects.iter().map( | v | format!( "< {}{:?} >", if v.optional { "?" } else { "" }, v.kind ) ).collect::< Vec< _ > >().join( " " ), + LevelOfDetail::Detailed => command.subjects.iter().map( | v | + { + format!( "< {}{:?} >", if v.optional { "?" } else { "" }, v.kind ) + }).collect::< Vec< _ > >().join( " " ), }; let properties = match o.property_detailing { LevelOfDetail::None => String::new(), _ if command.subjects.is_empty() => String::new(), LevelOfDetail::Simple => "< properties >".into(), - LevelOfDetail::Detailed => command.properties( dictionary.order ).iter().map( |( n, v )| format!( "< {}:{}{:?} >", if v.optional { "?" } else { "" }, n, v.kind ) ).collect::< Vec< _ > >().join( " " ), + LevelOfDetail::Detailed => command.properties( dictionary.order ).iter().map( | ( n, v ) | + { + format!( "< {}:{}{:?} >", if v.optional { "?" } else { "" }, n, v.kind ) + }).collect::< Vec< _ > >().join( " " ), }; let footer = if o.with_footer { - let full_subjects = command.subjects.iter().map( | subj | format!( "- {} [{}{:?}]", subj.hint, if subj.optional { "?" } else { "" }, subj.kind ) ).join( "\n\t" ); - let full_properties = format_table( command.properties( dictionary.order ).into_iter().map( | ( name, value ) | [ name.clone(), format!( "- {} [{}{:?}]", value.hint, if value.optional { "?" } else { "" }, value.kind ) ] ) ).unwrap().replace( '\n', "\n\t" ); + let full_subjects = command.subjects.iter().map( | subj | + { + format!( "- {} [{}{:?}]", subj.hint, if subj.optional { "?" } else { "" }, subj.kind ) + }).join( "\n\t" ); + let full_properties = format_table( command.properties( dictionary.order ).into_iter().map( | ( name, value ) | + { + [ name.clone(), format!( "- {} [{}{:?}]", value.hint, if value.optional { "?" } else { "" }, value.kind ) ] + })).unwrap().replace( '\n', "\n\t" ); format! ( @@ -149,7 +161,7 @@ mod private format! ( "{}{}{}", - format_table([[ row.name, row.args, row.hint ]]).unwrap(), + format_table( [ [ row.name, row.args, row.hint ] ] ).unwrap(), if row.footer.is_empty() { "" } else { "\n" }, row.footer ) @@ -160,7 +172,7 @@ mod private { let rows = dictionary.commands() .into_iter() - .map( |( _, cmd )| cmd ) + .map( | ( _, cmd ) | cmd ) .map( for_single_command ) .map( | row | [ row.name, row.args, row.hint ] ); format_table( rows ).unwrap() @@ -256,10 +268,10 @@ mod private let help = Command::former() .hint( "prints information about existing commands" ) .property( "format" ) - .hint( "help generates in format witch you write" ) - .kind( Type::String ) - .optional( true ) - .end() + .hint( "help generates in format witch you write" ) + .kind( Type::String ) + .optional( true ) + .end() .phrase( &phrase ) .routine( routine ) .form(); @@ -293,7 +305,7 @@ mod private let args = HelpGeneratorOptions::former() .command_prefix( "." ) - .for_commands([ cmd ]) + .for_commands( [ cmd ] ) .description_detailing( LevelOfDetail::Detailed ) .subject_detailing( LevelOfDetail::Simple ) .property_detailing( LevelOfDetail::Simple ) @@ -310,8 +322,16 @@ mod private let help = Command::former() .hint( "prints full information about a specified command" ) - .subject().hint( "command name" ).kind( Type::String ).optional( true ).end() - .property( "format" ).hint( "help generates in format witch you write" ).kind( Type::String ).optional( true ).end() + .subject() + .hint( "command name" ) + .kind( Type::String ) + .optional( true ) + .end() + .property( "format" ) + .hint( "help generates in format witch you write" ) + .kind( Type::String ) + .optional( true ) + .end() .phrase( &phrase ) .routine( routine ) .form(); @@ -412,7 +432,7 @@ mod private where HelpFunction : Fn( &Dictionary, HelpGeneratorOptions< '_ > ) -> String + 'static { - Self( Rc::new( func ) ) + Self( Rc::new( func ) ) } } diff --git a/module/move/wca/src/ca/parser/parser.rs b/module/move/wca/src/ca/parser/parser.rs index 4bee7321d0..2d6327691b 100644 --- a/module/move/wca/src/ca/parser/parser.rs +++ b/module/move/wca/src/ca/parser/parser.rs @@ -22,6 +22,9 @@ mod private #[ derive( Debug ) ] pub struct Parser; + // fix clippy error too large return type + type ParsedArgs = ( Vec< String >, HashMap< String, String >, usize ); + impl Parser { /// Parses a vector of command line arguments and returns a `Program` containing the parsed commands. @@ -42,7 +45,7 @@ mod private As : IntoIterator< Item = A >, A : Into< String >, { - let args: Vec< _ > = args.into_iter().map( Into::into ).collect(); + let args : Vec< _ > = args.into_iter().map( Into::into ).collect(); let mut commands = vec![]; let mut i = 0; while i < args.len() @@ -72,7 +75,8 @@ mod private // aaa : use typed error fn parse_command( args : &[ String ] ) -> Result< ( ParsedCommand, usize ), ParserError > { - if args.is_empty() { + if args.is_empty() + { return Err( ParserError::InternalError { details: "Try to parse command without input".into() } ); } @@ -90,7 +94,6 @@ mod private }; i += 1; let ( subjects, properties, relative_pos ) = Self::parse_command_args( &args[ i .. ] )?; - i += relative_pos; Ok( @@ -105,10 +108,13 @@ mod private )) } + + + // returns ( subjects, properties, relative_end_pos ) // aaa : use typed error // aaa : done - fn parse_command_args( args : &[ String ] ) -> Result< ( Vec< String >, HashMap< String, String >, usize ), ParserError > + fn parse_command_args( args : &[ String ] ) -> Result< ParsedArgs, ParserError > { let mut i = 0; @@ -177,7 +183,7 @@ mod private i += 1; } - Ok(( subjects, properties, i )) + Ok( ( subjects, properties, i ) ) } } } diff --git a/module/move/wca/src/ca/verifier/verifier.rs b/module/move/wca/src/ca/verifier/verifier.rs index db3de37923..bbcaed149c 100644 --- a/module/move/wca/src/ca/verifier/verifier.rs +++ b/module/move/wca/src/ca/verifier/verifier.rs @@ -2,7 +2,6 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - use help::{ HelpGeneratorOptions, LevelOfDetail, generate_help_content }; use grammar::{ Dictionary, Command, command::ValueDescription }; use executor::{ Args, Props }; @@ -18,8 +17,16 @@ mod private #[ error ( "Command not found. {} {}", - if let Some( phrase ) = name_suggestion { format!( "Maybe you mean `.{phrase}`?" ) } else { "Please use `.` command to see the list of available commands.".into() }, - if let Some( info ) = command_info { format!( "Command info: `{info}`" ) } else { "".into() } + if let Some( phrase ) = name_suggestion + { + format!( "Maybe you mean `.{phrase}`?" ) + } + else + { + "Please use `.` command to see the list of available commands.".into() + }, + // fix clippy + if let Some( info ) = command_info { format!( "Command info: `{info}`" ) } else { String::new() } )] CommandNotFound { name_suggestion: Option< String >, command_info: Option< String > }, #[ error( "Fail in command `.{command_name}` while processing subjects. {error}" ) ] @@ -130,8 +137,11 @@ mod private ) -> usize { raw_properties.iter() - .filter( |( k, _ )| !( properties.contains_key( *k ) || properties_aliases.get( *k ).map_or( false, | key | properties.contains_key( key ) ) ) ) - .count() + .filter( | ( k, _ ) | + { + !( properties.contains_key( *k ) || properties_aliases.get( *k ).map_or( false, | key | properties.contains_key( key ) ) ) + }) + .count() } fn is_valid_command_variant( subjects_count : usize, raw_count : usize, possible_count : usize ) -> bool @@ -211,8 +221,8 @@ mod private ) .collect() } - - fn group_properties_and_their_aliases< 'a, Ks >( aliases : &'a HashMap< String, String >, used_keys : Ks ) -> Vec< &String > + // fix clippy + fn group_properties_and_their_aliases< 'a, Ks >( aliases : &'a HashMap< String, String >, used_keys : Ks ) -> Vec<&'a String > where Ks : Iterator< Item = &'a String > { @@ -264,7 +274,7 @@ mod private #[ cfg( feature = "on_unknown_suggest" ) ] if let Some( phrase ) = Self::suggest_command( dictionary, &raw_command.name ) { - return VerificationError::CommandNotFound { name_suggestion: Some( phrase ), command_info: None }; + return VerificationError::CommandNotFound { name_suggestion: Some( phrase.to_string() ), command_info: None }; } VerificationError::CommandNotFound { name_suggestion: None, command_info: None } } diff --git a/module/move/wca/tests/inc/commands_aggregator/basic.rs b/module/move/wca/tests/inc/commands_aggregator/basic.rs index 6c9ba72c09..5f8464ff9b 100644 --- a/module/move/wca/tests/inc/commands_aggregator/basic.rs +++ b/module/move/wca/tests/inc/commands_aggregator/basic.rs @@ -10,7 +10,6 @@ use the_module:: ValidationError, }; -// tests_impls! { @@ -18,10 +17,10 @@ tests_impls! { let ca = CommandsAggregator::former() .command( "command" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "Command" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "Command" ) ) + .end() .perform(); a_id!( (), ca.perform( ".command" ).unwrap() ); // Parse -> Validate -> Execute @@ -31,11 +30,11 @@ tests_impls! { let ca = CommandsAggregator::former() .command( "command" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "Command" ) ) - .end() - .help_variants([ HelpVariants::General ]) + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "Command" ) ) + .end() + .help_variants( [ HelpVariants::General ] ) .perform(); a_id!( (), ca.perform( ".help" ).unwrap() ); // raw string -> GrammarProgram -> ExecutableProgram -> execute @@ -49,15 +48,15 @@ tests_impls! { let ca = CommandsAggregator::former() .command( "cmd.first" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "Command" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "Command" ) ) + .end() .command( "cmd.second" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "Command2" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "Command2" ) ) + .end() .perform(); a_id!( (), ca.perform( "." ).unwrap() ); @@ -68,15 +67,15 @@ tests_impls! { let ca = CommandsAggregator::former() .command( "command" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "command" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "command" ) ) + .end() .command( "command_with_execution_error" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || { println!( "command" ); Err( "runtime error" ) } ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || { println!( "command" ); Err( "runtime error" ) } ) + .end() .perform(); a_true!( ca.perform( ".command" ).is_ok() ); @@ -118,11 +117,11 @@ tests_impls! { let ca = CommandsAggregator::former() .command( "command" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .subject().hint( "A path to directory." ).kind( Type::Path ).optional( true ).end() - .routine( || println!( "hello" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .subject().hint( "A path to directory." ).kind( Type::Path ).optional( true ).end() + .routine( || println!( "hello" ) ) + .end() .perform(); let command = vec![ ".command".into(), "./path:to_dir".into() ]; @@ -219,7 +218,7 @@ tests_impls! let raw_command = parser.parse( [ ".command", "qwe:rty" ] ).unwrap().commands.remove( 0 ); let grammar_command = grammar.to_command( dictionary, raw_command ).unwrap(); - a_id!( grammar_command.args.0, vec![ the_module::Value::String("qwe:rty".into()) ] ); + a_id!( grammar_command.args.0, vec![ the_module::Value::String( "qwe:rty".into() ) ] ); a_id!( (), executor.command( dictionary, grammar_command ).unwrap() ); } @@ -232,11 +231,11 @@ tests_impls! let ca = CommandsAggregator::former() .command( "query.execute" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .subject().hint( "SQL query" ).kind( Type::String ).optional( false ).end() - .routine( move | o : VerifiedCommand | assert_eq!( query, o.args.get_owned::< &str >( 0 ).unwrap() ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .subject().hint( "SQL query" ).kind( Type::String ).optional( false ).end() + .routine( move | o : VerifiedCommand | assert_eq!( query, o.args.get_owned::< &str >( 0 ).unwrap() ) ) + .end() .perform(); a_id!( (), ca.perform( vec![ ".query.execute".to_string(), query.into() ] ).unwrap() ); diff --git a/module/move/wca/tests/inc/commands_aggregator/callback.rs b/module/move/wca/tests/inc/commands_aggregator/callback.rs index 21910a6560..03f696263d 100644 --- a/module/move/wca/tests/inc/commands_aggregator/callback.rs +++ b/module/move/wca/tests/inc/commands_aggregator/callback.rs @@ -10,15 +10,15 @@ fn changes_state_of_local_variable_on_perform() let ca_history = Arc::clone( &history ); let ca = CommandsAggregator::former() .command( "command" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "command" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "command" ) ) + .end() .command( "command2" ) - .hint( "hint" ) - .long_hint( "long_hint" ) - .routine( || println!( "command2" ) ) - .end() + .hint( "hint" ) + .long_hint( "long_hint" ) + .routine( || println!( "command2" ) ) + .end() .callback ( move | input, program | @@ -26,8 +26,8 @@ fn changes_state_of_local_variable_on_perform() .push( ( input.to_string(), - program.commands.clone() ) - )) + program.commands.clone() + ))) .perform(); { @@ -37,14 +37,14 @@ fn changes_state_of_local_variable_on_perform() { ca.perform( ".command" ).unwrap(); let current_history = history.lock().unwrap(); - assert_eq!( [ ".command" ], current_history.iter().map( |( input, _ )| input ).collect::< Vec< _ > >().as_slice() ); + assert_eq!( [ ".command" ], current_history.iter().map( | ( input, _ ) | input ).collect::< Vec< _ > >().as_slice() ); assert_eq!( 1, current_history.len() ); } { ca.perform( ".command2" ).unwrap(); let current_history = history.lock().unwrap(); - assert_eq!( [ ".command", ".command2" ], current_history.iter().map( |( input, _ )| input ).collect::< Vec< _ > >().as_slice() ); + assert_eq!( [ ".command", ".command2" ], current_history.iter().map( | ( input, _ ) | input ).collect::< Vec< _ > >().as_slice() ); assert_eq!( 2, current_history.len() ); } } diff --git a/module/move/wca/tests/inc/commands_aggregator/help.rs b/module/move/wca/tests/inc/commands_aggregator/help.rs index 2ce5a0bca5..db97e118b3 100644 --- a/module/move/wca/tests/inc/commands_aggregator/help.rs +++ b/module/move/wca/tests/inc/commands_aggregator/help.rs @@ -11,11 +11,22 @@ pub fn start_sync< AP, Args, Arg, P > application : AP, args: Args, path : P, -) -> String where AP : AsRef< Path >, Args : IntoIterator< Item = Arg >, Arg : AsRef< std::ffi::OsStr >, P : AsRef< Path >, +) -> String +where + AP : AsRef< Path >, + Args : IntoIterator< Item = Arg >, + Arg : AsRef< std::ffi::OsStr >, + P : AsRef< Path >, { let ( application, path ) = ( application.as_ref(), path.as_ref() ); let args: Vec< std::ffi::OsString > = args.into_iter().map( | a | a.as_ref().into() ).collect(); - let child = Command::new( application ).args( &args ).stdout( Stdio::piped() ).stderr( Stdio::piped() ).current_dir( path ).spawn().unwrap(); + let child = Command::new( application ) + .args( &args ) + .stdout( Stdio::piped() ) + .stderr( Stdio::piped() ) + .current_dir( path ) + .spawn() + .unwrap(); let output = child.wait_with_output().unwrap(); if !output.status.success() @@ -46,11 +57,11 @@ wca = {{path = "{}"}}"#, fn main(){ let ca = wca::CommandsAggregator::former() .command( "echo" ) - .hint( "prints all subjects and properties" ) - .subject().hint( "Subject" ).kind( Type::String ).optional( true ).end() - .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ) } ) - .end() + .hint( "prints all subjects and properties" ) + .subject().hint( "Subject" ).kind( Type::String ).optional( true ).end() + .property( "property" ).hint( "simple property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!( "= Args\n{:?}\n\n= Properties\n{:?}\n", o.args, o.props ) } ) + .end() .perform(); let args = std::env::args().skip( 1 ).collect::< Vec< String > >(); @@ -90,22 +101,22 @@ wca = {{path = "{}"}}"#, let ca = wca::CommandsAggregator::former() .command( "c" ) - .hint( "c" ) - .property( "c-property" ).kind( Type::String ).optional( true ).end() - .property( "b-property" ).kind( Type::String ).optional( true ).end() - .property( "a-property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!("c") } ) - .end() + .hint( "c" ) + .property( "c-property" ).kind( Type::String ).optional( true ).end() + .property( "b-property" ).kind( Type::String ).optional( true ).end() + .property( "a-property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!("c") } ) + .end() .command( "b" ) - .hint( "b" ) - .property( "b-property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!("b") } ) - .end() + .hint( "b" ) + .property( "b-property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!("b") } ) + .end() .command( "a" ) - .hint( "a" ) - .property( "a-property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!("a") } ) - .end() + .hint( "a" ) + .property( "a-property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!("a") } ) + .end() .order( Order::Nature ) .perform(); @@ -159,23 +170,23 @@ wca = {{path = "{}"}}"#, let ca = wca::CommandsAggregator::former() .command( "c" ) - .hint( "c" ) - .property( "c-property" ).kind( Type::String ).optional( true ).end() - .property( "b-property" ).kind( Type::String ).optional( true ).end() - .property( "a-property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!("c") } ) - .end() + .hint( "c" ) + .property( "c-property" ).kind( Type::String ).optional( true ).end() + .property( "b-property" ).kind( Type::String ).optional( true ).end() + .property( "a-property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!("c") } ) + .end() .command( "b" ) - .hint( "b" ) - .property( "b-property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!("b") } ) - .end() + .hint( "b" ) + .property( "b-property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!("b") } ) + .end() .command( "a" ) - .hint( "a" ) - .property( "a-property" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | { println!("a") } ) - .end() - .order( Order::Lexicography ) + .hint( "a" ) + .property( "a-property" ).kind( Type::String ).optional( true ).end() + .routine( | o : VerifiedCommand | { println!("a") } ) + .end() + .order( Order::Lexicography ) .perform(); let args = std::env::args().skip( 1 ).collect::< Vec< String > >(); diff --git a/module/move/wca/tests/inc/executor/command.rs b/module/move/wca/tests/inc/executor/command.rs index e489b90764..32c92425b1 100644 --- a/module/move/wca/tests/inc/executor/command.rs +++ b/module/move/wca/tests/inc/executor/command.rs @@ -57,7 +57,7 @@ tests_impls! .long_hint( "long_hint" ) .phrase( "command" ) .subject().hint( "hint" ).kind( Type::String ).optional( false ).end() - .routine( | o : VerifiedCommand | o.args.get( 0 ).map( | a | println!( "{a:?}" )).ok_or_else( || "Subject not found" ) ) + .routine( | o : VerifiedCommand | o.args.get( 0 ).map( | a | println!( "{a:?}" ) ).ok_or_else( || "Subject not found" ) ) .form() ) .form(); @@ -93,7 +93,7 @@ tests_impls! .long_hint( "long_hint" ) .phrase( "command" ) .property( "prop" ).hint( "about prop" ).kind( Type::String ).optional( true ).end() - .routine( | o : VerifiedCommand | o.props.get( "prop" ).map( | a | println!( "{a:?}" )).ok_or_else( || "Prop not found" ) ) + .routine( | o : VerifiedCommand | o.props.get( "prop" ).map( | a | println!( "{a:?}" ) ).ok_or_else( || "Prop not found" ) ) .form() ) .form(); diff --git a/module/move/wca/tests/inc/grammar/from_command.rs b/module/move/wca/tests/inc/grammar/from_command.rs index 343cde7ffb..1776539288 100644 --- a/module/move/wca/tests/inc/grammar/from_command.rs +++ b/module/move/wca/tests/inc/grammar/from_command.rs @@ -247,14 +247,14 @@ tests_impls! let grammar_command = verifier.to_command( dictionary, raw_command ).unwrap(); a_true!( grammar_command.args.0.is_empty() ); - a_id!( HashMap::from_iter([ ( "prop1".to_string(), Value::String( "value1".to_string() ) ) ]), grammar_command.props.0 ); + a_id!( HashMap::from_iter( [ ( "prop1".to_string(), Value::String( "value1".to_string() ) ) ] ), grammar_command.props.0 ); // with property re-write let raw_command = parser.parse( [ ".command", "prop1:value", "prop1:another_value" ] ).unwrap().commands.remove( 0 ); let grammar_command = verifier.to_command( dictionary, raw_command ).unwrap(); a_true!( grammar_command.args.0.is_empty() ); - a_id!( HashMap::from_iter([ ( "prop1".to_string(), Value::String( "another_value".to_string() ) ) ]), grammar_command.props.0 ); + a_id!( HashMap::from_iter( [ ( "prop1".to_string(), Value::String( "another_value".to_string() ) ) ] ), grammar_command.props.0 ); // with undeclareted property let raw_command = parser.parse( [ ".command", "undeclareted_prop:value" ] ).unwrap().commands.remove( 0 ); @@ -342,12 +342,12 @@ tests_impls! .long_hint( "long_hint" ) .phrase( "command" ) .property( "property" ) - .hint( "string property" ) - .kind( Type::String ) - .optional( true ) - .alias( "prop" ) - .alias( "p" ) - .end() + .hint( "string property" ) + .kind( Type::String ) + .optional( true ) + .alias( "prop" ) + .alias( "p" ) + .end() .form() ) .form(); @@ -358,21 +358,21 @@ tests_impls! let grammar_command = verifier.to_command( dictionary, raw_command ).unwrap(); a_true!( grammar_command.args.0.is_empty() ); - a_id!( HashMap::from_iter([ ( "property".to_string(), Value::String( "value".to_string() ) ) ]), grammar_command.props.0 ); + a_id!( HashMap::from_iter( [ ( "property".to_string(), Value::String( "value".to_string() ) ) ] ), grammar_command.props.0 ); // first alias let raw_command = parser.parse( [ ".command", "prop:value" ] ).unwrap().commands.remove( 0 ); let grammar_command = verifier.to_command( dictionary, raw_command ).unwrap(); a_true!( grammar_command.args.0.is_empty() ); - a_id!( HashMap::from_iter([ ( "property".to_string(), Value::String( "value".to_string() ) ) ]), grammar_command.props.0 ); + a_id!( HashMap::from_iter( [ ( "property".to_string(), Value::String( "value".to_string() ) ) ] ), grammar_command.props.0 ); // second alias let raw_command = parser.parse( [ ".command", "p:value" ] ).unwrap().commands.remove( 0 ); let grammar_command = verifier.to_command( dictionary, raw_command ).unwrap(); a_true!( grammar_command.args.0.is_empty() ); - a_id!( HashMap::from_iter([ ( "property".to_string(), Value::String( "value".to_string() ) ) ]), grammar_command.props.0 ); + a_id!( HashMap::from_iter( [ ( "property".to_string(), Value::String( "value".to_string() ) ) ] ), grammar_command.props.0 ); // init converter with layered properties let dictionary = &Dictionary::former() @@ -393,7 +393,7 @@ tests_impls! let grammar_command = verifier.to_command( dictionary, raw_command ).unwrap(); a_true!( grammar_command.args.0.is_empty() ); - a_id!( HashMap::from_iter([ ( "property".to_string(), Value::String( "value".to_string() ) ) ]), grammar_command.props.0 ); + a_id!( HashMap::from_iter( [ ( "property".to_string(), Value::String( "value".to_string() ) ) ] ), grammar_command.props.0 ); } } diff --git a/module/move/wca/tests/inc/grammar/types.rs b/module/move/wca/tests/inc/grammar/types.rs index b04ab6c346..037cdb3177 100644 --- a/module/move/wca/tests/inc/grammar/types.rs +++ b/module/move/wca/tests/inc/grammar/types.rs @@ -116,9 +116,10 @@ tests_impls! // numbers let numbers = Type::List( Type::Number.into(), ';' ).try_cast( "100;3.14".into() ); let numbers = numbers.unwrap(); - a_id!( - Value::List( vec![ Value::Number( 100.0 ), Value::Number( 3.14 ) ] ) - , numbers ); + a_id! + ( + Value::List( vec![ Value::Number( 100.0 ), Value::Number( 3.14 ) ] ), numbers + ); let inner_numbers : Vec< i32 > = numbers.clone().into(); a_id!( vec![ 100, 3 ], inner_numbers ); diff --git a/module/move/wca/tests/inc/parser/command.rs b/module/move/wca/tests/inc/parser/command.rs index 7f5c1aecf4..e11f427695 100644 --- a/module/move/wca/tests/inc/parser/command.rs +++ b/module/move/wca/tests/inc/parser/command.rs @@ -52,7 +52,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "prop".into(), "value".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "value".into() ) ] ), }, parser.parse( [ ".command", "prop:value" ] ).unwrap().commands[ 0 ] ); @@ -81,7 +81,7 @@ tests_impls! { name : "command".into(), subjects : vec![ "subject".into() ], - properties : HashMap::from_iter([ ( "prop".into(), "value".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "value".into() ) ] ), }, parser.parse( [ ".command", "subject", "prop:value" ] ).unwrap().commands[ 0 ] ); @@ -132,7 +132,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "value with spaces".into() ) ] ), }, parser.parse( [ ".command", "prop:value with spaces" ] ).unwrap().commands[ 0 ] ); @@ -143,7 +143,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "value with spaces".into() ) ] ), }, parser.parse( [ ".command", "prop:", "value with spaces" ] ).unwrap().commands[ 0 ] ); @@ -154,7 +154,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "value with spaces".into() ) ] ), }, parser.parse( [ ".command", "prop", ":value with spaces" ] ).unwrap().commands[ 0 ] ); @@ -165,7 +165,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "prop".into(), "value with spaces".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "value with spaces".into() ) ] ), }, parser.parse( [ ".command", "prop", ":", "value with spaces" ] ).unwrap().commands[ 0 ] ); @@ -203,7 +203,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "long_prop".into(), "some-value".into() ) ]), + properties : HashMap::from_iter( [ ( "long_prop".into(), "some-value".into() ) ] ), }, parser.parse( [ ".command", "long_prop:some-value" ] ).unwrap().commands[ 0 ] ); @@ -246,7 +246,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "path".into(), "/absolute/path/to/something".into() ) ]), + properties : HashMap::from_iter( [ ( "path".into(), "/absolute/path/to/something".into() ) ] ), }, parser.parse( [ ".command", "path:/absolute/path/to/something" ] ).unwrap().commands[ 0 ] ); @@ -257,7 +257,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "path".into(), "./path/to/something".into() ) ]), + properties : HashMap::from_iter( [ ( "path".into(), "./path/to/something".into() ) ] ), }, parser.parse( [ ".command", "path:./path/to/something" ] ).unwrap().commands[ 0 ] ); @@ -268,7 +268,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "path".into(), "../path/to/something".into() ) ]), + properties : HashMap::from_iter( [ ( "path".into(), "../path/to/something".into() ) ] ), }, parser.parse( [ ".command", "path:../path/to/something" ] ).unwrap().commands[ 0 ] ); @@ -284,7 +284,7 @@ tests_impls! { name : "command".into(), subjects : vec![], - properties : HashMap::from_iter([ ( "list".into(), "[1,2,3]".into() ) ]), + properties : HashMap::from_iter( [ ( "list".into(), "[1,2,3]".into() ) ] ), }, parser.parse( [ ".command", "list:[1,2,3]" ] ).unwrap().commands[ 0 ] ); @@ -300,7 +300,7 @@ tests_impls! { name : "command".into(), subjects : vec![ "subject with spaces".into() ], - properties : HashMap::from_iter([ ( "prop".into(), "property with spaces".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "property with spaces".into() ) ] ), }, parser.parse( [ ".command", "subject with spaces", "prop:property with spaces" ] ).unwrap().commands[ 0 ] ); @@ -312,7 +312,7 @@ tests_impls! { name : "command".into(), subjects : vec![ "\\.command".into() ], - properties : HashMap::from_iter([ ( "prop".into(), ".command".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), ".command".into() ) ] ), }, parser.parse( [ ".command", "\\.command", "prop:.command" ] ).unwrap().commands[ 0 ] ); @@ -324,7 +324,7 @@ tests_impls! { name : "command".into(), subjects : vec![ "' queted ' \\ value".into() ], - properties : HashMap::from_iter([ ( "prop".into(), "some \"quetes\" ' \\ in string".into() ) ]), + properties : HashMap::from_iter( [ ( "prop".into(), "some \"quetes\" ' \\ in string".into() ) ] ), }, parser.parse( [ ".command", "\' queted \' \\ value", "prop:some \"quetes\" ' \\ in string" ] ).unwrap().commands[ 0 ] ); diff --git a/module/move/willbe/src/action/cicd_renew.rs b/module/move/willbe/src/action/cicd_renew.rs index ca46b77549..cec1aae1c8 100644 --- a/module/move/willbe/src/action/cicd_renew.rs +++ b/module/move/willbe/src/action/cicd_renew.rs @@ -9,7 +9,7 @@ mod private io::{ Write, Read }, }; - use path::{ Path }; + use path::Path; use collection::BTreeMap; use convert_case::{ Casing, Case }; use handlebars::{ RenderError, TemplateError }; @@ -382,7 +382,7 @@ mod private url::repo_url_extract( &url ) .and_then( | url | url::git_info_extract( &url ).ok() ) .map( UsernameAndRepository ) - .ok_or_else( || error::untyped::format_err!( "Fail to parse repository url from workspace Cargo.toml")) + .ok_or_else( || error::untyped::format_err!( "Fail to parse repository url from workspace Cargo.toml") ) } else { diff --git a/module/move/willbe/src/action/deploy_renew.rs b/module/move/willbe/src/action/deploy_renew.rs index c0681cc6c7..562f8c1487 100644 --- a/module/move/willbe/src/action/deploy_renew.rs +++ b/module/move/willbe/src/action/deploy_renew.rs @@ -3,7 +3,7 @@ mod private #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::path::Path; - use error::{ untyped::Context }; + use error::untyped::Context; #[ allow( clippy::wildcard_imports ) ] use tool::template::*; @@ -45,7 +45,10 @@ mod private { let formed = TemplateFilesBuilder::former() // root - .file().data( include_str!( "../../template/deploy/.deploy_template.toml.hbs" ) ).path( "./.deploy_template.toml" ).mode( WriteMode::TomlExtend ).is_template( true ).end() + .file().data( include_str!( "../../template/deploy/.deploy_template.toml.hbs" ) ).path( "./.deploy_template.toml" ) + .mode( WriteMode::TomlExtend ) + .is_template( true ) + .end() .file().data( include_str!( "../../template/deploy/Makefile.hbs" ) ).path( "./Makefile" ).is_template( true ).end() // /key .file().data( include_str!( "../../template/deploy/key/pack.sh" ) ).path( "./key/pack.sh" ).end() diff --git a/module/move/willbe/src/action/features.rs b/module/move/willbe/src/action/features.rs index 2d46a8a882..5bccd0a266 100644 --- a/module/move/willbe/src/action/features.rs +++ b/module/move/willbe/src/action/features.rs @@ -12,7 +12,7 @@ mod private // // use path::AbsolutePath; use former::Former; - use error::{ untyped::Context }; + use error::untyped::Context; // use workspace::Workspace; /// Options available for the .features command @@ -42,20 +42,19 @@ mod private impl fmt::Display for FeaturesReport { #[ allow( clippy::match_bool ) ] - fn fmt( &self, f : &mut fmt::Formatter< '_ >) -> Result< (), fmt::Error > + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> Result< (), fmt::Error > { self.inner.iter().try_for_each ( | ( package, features ) | { - writeln!(f, "Package {package}:")?; + writeln!( f, "Package {package}:" )?; features.iter().try_for_each ( | ( feature, dependencies ) | { let feature = match self.with_features_deps { false => format!( "\t{feature}" ), - true - => + true => { let deps = dependencies.join( ", " ); format!( "\t{feature}: [{deps}]" ) @@ -83,7 +82,7 @@ mod private { if let Ok( manifest_file ) = package.manifest_file() { - manifest_file.inner().starts_with(crate_dir.clone().absolute_path()) + manifest_file.inner().starts_with( crate_dir.clone().absolute_path() ) } else { @@ -101,11 +100,12 @@ mod private packages // .iter() .for_each - ( | package | - { - let features = package.features(); - report.inner.insert(package.name().to_owned(), features.to_owned()); - } + ( + | package | + { + let features = package.features(); + report.inner.insert( package.name().to_owned(), features.to_owned() ); + } ); Ok( report ) } diff --git a/module/move/willbe/src/action/list.rs b/module/move/willbe/src/action/list.rs index 5bd66e940c..baa74feed0 100644 --- a/module/move/willbe/src/action/list.rs +++ b/module/move/willbe/src/action/list.rs @@ -41,7 +41,7 @@ mod private { "tree" => ListFormat::Tree, "toposort" => ListFormat::Topological, - e => return Err( error::untyped::format_err!( "Unknown format '{}'. Available values : [tree, toposort]", e )) + e => return Err( error::untyped::format_err!( "Unknown format '{}'. Available values : [tree, toposort]", e ) ) }; Ok( value ) @@ -295,7 +295,7 @@ mod private ( f, "{}", - v.iter().enumerate().map( |( i, v )| format!( "[{i}] {v}" ) ).collect::< Vec< _ > >().join( "\n" ) + v.iter().enumerate().map( | ( i, v ) | format!( "[{i}] {v}" ) ).collect::< Vec< _ > >().join( "\n" ) ), Self::Empty => write!( f, "Nothing" ), @@ -440,8 +440,7 @@ mod private /// or a tuple containing the list report and error if not successful. #[ cfg_attr( feature = "tracing", tracing::instrument ) ] pub fn list_all( args : ListOptions ) - -> - ResultWithReport< ListReport, error::untyped::Error > // qqq : should be specific error + -> ResultWithReport< ListReport, error::untyped::Error > // qqq : should be specific error // qqq : use typed error { let mut report = ListReport::default(); @@ -503,7 +502,7 @@ mod private *report = match report { ListReport::Tree( ref mut v ) => ListReport::Tree - ( { v.extend([ printer ]); v.clone() } ), + ( { v.extend( [ printer ] ); v.clone() } ), ListReport::Empty => ListReport::Tree( vec![ printer ] ), ListReport::List( _ ) => unreachable!(), }; @@ -612,7 +611,7 @@ mod private ) .err_with_report( &report )?; let packages_info : collection::HashMap< String, WorkspacePackageRef< '_ > > = - packages.map( | p | ( p.name().to_string(), p ) ).collect(); + packages.map( | p | ( p.name().to_string(), p ) ).collect(); if root_crate.is_empty() { @@ -642,7 +641,7 @@ mod private Ok::< String, PathError >( name ) } ) - .collect::< Result< _, _ >>() + .collect::< Result< _, _ > >() .err_with_report( &report )?; report = ListReport::List( names ); @@ -733,7 +732,7 @@ mod private .chain( report.dev_dependencies.iter_mut() ) .chain( report.build_dependencies.iter_mut() ) { - build_deps_acc = merge_build_dependencies_impl(dep, build_deps_acc ); + build_deps_acc = merge_build_dependencies_impl( dep, build_deps_acc ); } for dep in std::mem::take( &mut report.build_dependencies ) @@ -792,7 +791,7 @@ mod private fn rearrange_duplicates( mut report : Vec< tool::ListNodeReport > ) -> Vec< tool::TreePrinter > { let mut required_normal : collection::HashMap< usize, Vec< tool::ListNodeReport > > = collection::HashMap::new(); - for (i, report) in report.iter_mut().enumerate() + for ( i, report ) in report.iter_mut().enumerate() { let ( required, exist ) : ( Vec< _ >, Vec< _ > ) = std::mem::take ( @@ -832,11 +831,10 @@ mod private if !node.duplicate { - if let Some( r ) = required.iter_mut().flat_map( |( _, v )| v ) + if let Some( r ) = required.iter_mut().flat_map( | ( _, v ) | v ) .find ( - | r | - r.name == node.name && r.version == node.version && r.crate_dir == node.crate_dir + | r | r.name == node.name && r.version == node.version && r.crate_dir == node.crate_dir ) { std::mem::swap( r, node ); diff --git a/module/move/willbe/src/action/main_header.rs b/module/move/willbe/src/action/main_header.rs index 41241c2ffb..0989fba06b 100644 --- a/module/move/willbe/src/action/main_header.rs +++ b/module/move/willbe/src/action/main_header.rs @@ -4,10 +4,7 @@ mod private #[ allow( clippy::wildcard_imports ) ] use crate::*; use std::fmt::{ Display, Formatter }; - use std::fs:: - { - OpenOptions - }; + use std::fs::OpenOptions; use std::io:: { Read, @@ -166,7 +163,11 @@ mod private r#"[![{}](https://img.shields.io/github/actions/workflow/status/{}/standard_rust_scheduled.yml?label={}&logo=github&branch={})](https://github.com/{}/actions/workflows/standard_rust_scheduled.yml){} [![Open in Gitpod](https://raster.shields.io/static/v1?label=try&message=online&color=eee&logo=gitpod&logoColor=eee)](https://gitpod.io/#RUN_PATH=.,SAMPLE_FILE=sample%2Frust%2F{}_trivial_sample%2Fsrc%2Fmain.rs,RUN_POSTFIX=--example%20{}_trivial_sample/https://github.com/{}) [![docs.rs](https://raster.shields.io/static/v1?label=docs&message=online&color=eee&logo=docsdotrs&logoColor=eee)](https://docs.rs/{})"#, - self.workspace_name, url::git_info_extract( &self.repository_url )?, self.workspace_name, self.master_branch, url::git_info_extract( &self.repository_url )?, + self.workspace_name, + url::git_info_extract( &self.repository_url )?, + self.workspace_name, + self.master_branch, + url::git_info_extract( &self.repository_url )?, discord, self.workspace_name.to_lowercase(), self.workspace_name.to_lowercase(), url::git_info_extract( &self.repository_url )?, self.workspace_name, diff --git a/module/move/willbe/src/action/publish.rs b/module/move/willbe/src/action/publish.rs index ed6a6c90f2..9230753d96 100644 --- a/module/move/willbe/src/action/publish.rs +++ b/module/move/willbe/src/action/publish.rs @@ -4,7 +4,6 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - use std::{ env, fmt, fs }; use { @@ -36,7 +35,7 @@ mod private writeln!( f, "Actions :" )?; for ( path, report ) in &self.packages { - let report = report.to_string().replace('\n', "\n "); + let report = report.to_string().replace( '\n', "\n " ); let path = if let Some( wrd ) = &self.workspace_root_dir { path.as_ref().strip_prefix( wrd.as_ref() ).unwrap() @@ -67,7 +66,7 @@ mod private let mut actually_published : Vec< _ > = self.packages.iter() .filter_map ( - |( path, repo )| + | ( path, repo ) | if repo.publish.as_ref().is_some_and( | r | r.error.is_ok() ) { Some( path.clone() ) @@ -265,7 +264,7 @@ mod private for package_report in publish::perform_packages_publish( plan ).err_with_report( &report )? { let path : &std::path::Path = package_report.get_info.as_ref().unwrap().current_path.as_ref(); - report.packages.push(( AbsolutePath::try_from( path ).unwrap(), package_report )); + report.packages.push( ( AbsolutePath::try_from( path ).unwrap(), package_report ) ); } if let Some( dir ) = temp diff --git a/module/move/willbe/src/action/publish_diff.rs b/module/move/willbe/src/action/publish_diff.rs index 69b98be647..4cacfa4a94 100644 --- a/module/move/willbe/src/action/publish_diff.rs +++ b/module/move/willbe/src/action/publish_diff.rs @@ -4,13 +4,11 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - use path::PathBuf; use collection::HashMap; use std::fmt; use colored::Colorize; use crates_tools::CrateArchive; - use action::list::ListReport; use error::untyped::Result; // qqq : group dependencies @@ -114,9 +112,9 @@ mod private action::list::ListOptions::former() .path_to_manifest( dir ) .format( action::list::ListFormat::Tree ) - .info([ action::list::PackageAdditionalInfo::Version, action::list::PackageAdditionalInfo::Path ]) - .dependency_sources([ action::list::DependencySource::Local ]) - .dependency_categories([ action::list::DependencyCategory::Primary ]) + .info( [ action::list::PackageAdditionalInfo::Version, action::list::PackageAdditionalInfo::Path ] ) + .dependency_sources( [ action::list::DependencySource::Local ] ) + .dependency_categories( [ action::list::DependencyCategory::Primary ] ) .form() ) .unwrap(); diff --git a/module/move/willbe/src/action/readme_health_table_renew.rs b/module/move/willbe/src/action/readme_health_table_renew.rs index dff994b1d9..e18bc551b5 100644 --- a/module/move/willbe/src/action/readme_health_table_renew.rs +++ b/module/move/willbe/src/action/readme_health_table_renew.rs @@ -111,7 +111,7 @@ mod private else { // qqq : for Petro : use typed error - Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Cannot find Cargo.toml" ))) + Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Cannot find Cargo.toml" ) ) ) } } @@ -197,7 +197,7 @@ mod private let cargo_toml_path = path.join( "Cargo.toml" ); if !cargo_toml_path.exists() { - return Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Cannot find Cargo.toml" ))) + return Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Cannot find Cargo.toml" ) ) ) } let mut contents = String::new(); @@ -217,7 +217,7 @@ mod private .get( "workspace" ) .and_then( | workspace | workspace.get( "metadata" ) ) .and_then( | metadata | metadata.get( "branches" ) ) - .and_then( | branches | branches.as_array()) + .and_then( | branches | branches.as_array() ) .map ( | array | @@ -618,11 +618,16 @@ ensure that at least one remotest is present in git. ", { match stability { - Stability::Experimental => " [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental)".into(), - Stability::Stable => " [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable)".into(), - Stability::Deprecated => " [![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated)".into(), - Stability::Unstable => " [![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)](https://github.com/emersion/stability-badges#unstable)".into(), - Stability::Frozen => " [![stability-frozen](https://img.shields.io/badge/stability-frozen-blue.svg)](https://github.com/emersion/stability-badges#frozen)".into(), + Stability::Experimental => + " [![experimental](https://raster.shields.io/static/v1?label=&message=experimental&color=orange)](https://github.com/emersion/stability-badges#experimental)".into(), + Stability::Stable => + " [![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/emersion/stability-badges#stable)".into(), + Stability::Deprecated => + " [![stability-deprecated](https://img.shields.io/badge/stability-deprecated-red.svg)](https://github.com/emersion/stability-badges#deprecated)".into(), + Stability::Unstable => + " [![stability-unstable](https://img.shields.io/badge/stability-unstable-yellow.svg)](https://github.com/emersion/stability-badges#unstable)".into(), + Stability::Frozen => + " [![stability-frozen](https://img.shields.io/badge/stability-frozen-blue.svg)](https://github.com/emersion/stability-badges#frozen)".into(), } } @@ -709,7 +714,7 @@ ensure that at least one remotest is present in git. ", target.extend_from_slice( &source[ from..= to ] ); return Ok( () ) } - Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Incorrect indexes" ))) + Err( HealthTableRenewError::Common( error::untyped::Error::msg( "Incorrect indexes" ) ) ) } } diff --git a/module/move/willbe/src/action/readme_modules_headers_renew.rs b/module/move/willbe/src/action/readme_modules_headers_renew.rs index 33b12bc29b..3f6f4254dc 100644 --- a/module/move/willbe/src/action/readme_modules_headers_renew.rs +++ b/module/move/willbe/src/action/readme_modules_headers_renew.rs @@ -143,7 +143,10 @@ mod private let stability = package.stability()?; let module_name = package.name()?; let repository_url = package.repository()? - .ok_or_else::< error::untyped::Error, _ >( || error::untyped::format_err!( "Fail to find repository_url in module`s Cargo.toml" ) )?; + .ok_or_else::< error::untyped::Error, _ > + ( + || error::untyped::format_err!( "Fail to find repository_url in module`s Cargo.toml" ) + )?; let discord_url = package .discord_url()? diff --git a/module/move/willbe/src/action/test.rs b/module/move/willbe/src/action/test.rs index 2e23df5108..4cb28966aa 100644 --- a/module/move/willbe/src/action/test.rs +++ b/module/move/willbe/src/action/test.rs @@ -92,16 +92,18 @@ mod private // aaa : for Petro : non readable // aaa : readable and with actual command return Err - (( - report, - format_err! + ( ( - "Missing toolchain(-s) that was required : [{}]. \ + report, + format_err! + ( + "Missing toolchain(-s) that was required : [{}]. \ Try to install it with `rustup install {}` command(-s)", - channels_diff.iter().join( ", " ), - channels_diff.iter().join( " " ) - ) - )) + channels_diff.iter().join( ", " ), + channels_diff.iter().join( " " ) + ) + ) + ) } report.dry = dry; let TestsCommandOptions diff --git a/module/move/willbe/src/action/workspace_renew.rs b/module/move/willbe/src/action/workspace_renew.rs index ee27334708..da6bf4bb2f 100644 --- a/module/move/willbe/src/action/workspace_renew.rs +++ b/module/move/willbe/src/action/workspace_renew.rs @@ -63,57 +63,57 @@ mod private { let formed = TemplateFilesBuilder::former() .file() - .data( include_str!( "../../template/workspace/.gitattributes" ) ) - .path( "./.gitattributes" ) - .end() + .data( include_str!( "../../template/workspace/.gitattributes" ) ) + .path( "./.gitattributes" ) + .end() .file() - .data( include_str!( "../../template/workspace/.gitignore1" ) ) - .path( "./.gitignore" ) - .end() + .data( include_str!( "../../template/workspace/.gitignore1" ) ) + .path( "./.gitignore" ) + .end() .file() - .data( include_str!( "../../template/workspace/.gitpod.yml" ) ) - .path( "./.gitpod.yml" ) - .end() + .data( include_str!( "../../template/workspace/.gitpod.yml" ) ) + .path( "./.gitpod.yml" ) + .end() .file() - .data( include_str!( "../../template/workspace/Cargo.hbs" ) ) - .path( "./Cargo.toml" ) - .is_template( true ) - .end() + .data( include_str!( "../../template/workspace/Cargo.hbs" ) ) + .path( "./Cargo.toml" ) + .is_template( true ) + .end() .file() - .data( include_str!( "../../template/workspace/Makefile" ) ) - .path( "./Makefile" ) - .end() + .data( include_str!( "../../template/workspace/Makefile" ) ) + .path( "./Makefile" ) + .end() .file() - .data( include_str!( "../../template/workspace/Readme.md" ) ) - .path( "./Readme.md" ) - .end() + .data( include_str!( "../../template/workspace/Readme.md" ) ) + .path( "./Readme.md" ) + .end() .file() - .data( include_str!( "../../template/workspace/.cargo/config.toml" ) ) - .path( "./.cargo/config.toml" ) - .end() + .data( include_str!( "../../template/workspace/.cargo/config.toml" ) ) + .path( "./.cargo/config.toml" ) + .end() .file() - .data( include_str!( "../../template/workspace/module/module1/Cargo.toml.x" ) ) - .path( "./module/Cargo.toml" ) - .end() + .data( include_str!( "../../template/workspace/module/module1/Cargo.toml.x" ) ) + .path( "./module/Cargo.toml" ) + .end() .file() - .data( include_str!( "../../template/workspace/module/module1/Readme.md" ) ) - .path( "./module/module1/Readme.md" ) - .end() + .data( include_str!( "../../template/workspace/module/module1/Readme.md" ) ) + .path( "./module/module1/Readme.md" ) + .end() .file() - .data - ( - include_str!( "../../template/workspace/module/module1/examples/module1_example.rs" ) - ) - .path( "./module/module1/examples/module1_example.rs" ) - .end() + .data + ( + include_str!( "../../template/workspace/module/module1/examples/module1_example.rs" ) + ) + .path( "./module/module1/examples/module1_example.rs" ) + .end() .file() - .data( include_str!( "../../template/workspace/module/module1/src/lib.rs" ) ) - .path( "./module/module1/src/lib.rs" ) - .end() + .data( include_str!( "../../template/workspace/module/module1/src/lib.rs" ) ) + .path( "./module/module1/src/lib.rs" ) + .end() .file() - .data( include_str!( "../../template/workspace/module/module1/tests/hello_test.rs" ) ) - .path( "./module/module1/tests/hello_test.rs" ) - .end() + .data( include_str!( "../../template/workspace/module/module1/tests/hello_test.rs" ) ) + .path( "./module/module1/tests/hello_test.rs" ) + .end() .form(); Self( formed.files ) diff --git a/module/move/willbe/src/command/list.rs b/module/move/willbe/src/command/list.rs index d474c313b1..d7e20e4c73 100644 --- a/module/move/willbe/src/command/list.rs +++ b/module/move/willbe/src/command/list.rs @@ -11,7 +11,7 @@ mod private path::PathBuf, }; use wca::VerifiedCommand; - use error::{ untyped::Context }; + use error::untyped::Context; use collection::HashSet; use action:: @@ -91,7 +91,7 @@ mod private { println!( "{report}" ); } - Err(( report, e )) => + Err( ( report, e ) ) => { eprintln!( "{report}" ); diff --git a/module/move/willbe/src/command/publish.rs b/module/move/willbe/src/command/publish.rs index 5b3afd8930..8d823eacc5 100644 --- a/module/move/willbe/src/command/publish.rs +++ b/module/move/willbe/src/command/publish.rs @@ -5,9 +5,8 @@ mod private #[ allow( clippy::wildcard_imports ) ] use crate::*; use colored::Colorize; - use wca::VerifiedCommand; - use error::{ untyped::Context }; // xxx + use error::untyped::Context; // xxx use former::Former; use std::fmt::Write; use channel::Channel; diff --git a/module/move/willbe/src/command/test.rs b/module/move/willbe/src/command/test.rs index 118f44f8d6..9e450078b8 100644 --- a/module/move/willbe/src/command/test.rs +++ b/module/move/willbe/src/command/test.rs @@ -130,7 +130,7 @@ Set at least one of them to true." ); let args = if args_line.is_empty() { String::new() } else { format!(" {args_line}" ) }; let prop = if prop_line.is_empty() { String::new() } else { format!(" {prop_line}" ) }; let line = format!( "will .publish{args}{prop} dry:0" ); - println!("To apply plan, call the command `{}`", line.blue()); + println!( "To apply plan, call the command `{}`", line.blue() ); } else { diff --git a/module/move/willbe/src/command/workspace_renew.rs b/module/move/willbe/src/command/workspace_renew.rs index a77254accd..3590c85485 100644 --- a/module/move/willbe/src/command/workspace_renew.rs +++ b/module/move/willbe/src/command/workspace_renew.rs @@ -4,9 +4,8 @@ mod private #[ allow( clippy::wildcard_imports ) ] use crate::*; use former::Former; - use wca::VerifiedCommand; - use error::{ untyped::Context }; + use error::untyped::Context; use action::WorkspaceTemplate; #[ derive( Former ) ] diff --git a/module/move/willbe/src/entity/channel.rs b/module/move/willbe/src/entity/channel.rs index 92aa9f95d7..c073db2922 100644 --- a/module/move/willbe/src/entity/channel.rs +++ b/module/move/willbe/src/entity/channel.rs @@ -79,7 +79,7 @@ mod private "stable" => Some( Channel::Stable ), "nightly" => Some( Channel::Nightly ), _ => None - } ) + }) .collect(); Ok( list ) diff --git a/module/move/willbe/src/entity/diff.rs b/module/move/willbe/src/entity/diff.rs index 9f6f4b7709..6298a5762f 100644 --- a/module/move/willbe/src/entity/diff.rs +++ b/module/move/willbe/src/entity/diff.rs @@ -4,10 +4,7 @@ mod private #[ allow( clippy::wildcard_imports ) ] use crate::*; - use std:: - { - fmt::Formatter, - }; + use std::fmt::Formatter; use path::PathBuf; use collection::HashMap; use colored::Colorize; @@ -102,7 +99,7 @@ mod private #[ must_use ] pub fn has_changes( &self ) -> bool { - !self.0.iter().all( |( _, item )| matches!( item, DiffItem::File( Diff::Same( () ) ) )) + !self.0.iter().all( | ( _, item ) | matches!( item, DiffItem::File( Diff::Same( () ) ) ) ) } } @@ -110,7 +107,7 @@ mod private { fn fmt( &self, f : &mut Formatter< '_ > ) -> std::fmt::Result { - for ( path , diff ) in self.0.iter().sorted_by_key( |( k, _ )| k.as_path() ) + for ( path , diff ) in self.0.iter().sorted_by_key( | ( k, _ ) | k.as_path() ) { match diff { diff --git a/module/move/willbe/src/entity/features.rs b/module/move/willbe/src/entity/features.rs index 8212fdef42..ae7cfabd64 100644 --- a/module/move/willbe/src/entity/features.rs +++ b/module/move/willbe/src/entity/features.rs @@ -63,7 +63,7 @@ mod private let filtered_features : BTreeSet< _ > = package .features() .keys() - .filter( | f | !exclude_features.contains( f ) && (include_features.contains(f) || include_features.is_empty()) ) + .filter( | f | !exclude_features.contains( f ) && ( include_features.contains(f) || include_features.is_empty() ) ) .cloned() .collect(); @@ -110,8 +110,7 @@ mod private with_none_features : bool, enabled_features : &[ String ], total_features : usize - ) - -> usize + ) -> usize { let mut estimate = 0; let mut binom = 1; diff --git a/module/move/willbe/src/entity/files/crate_dir.rs b/module/move/willbe/src/entity/files/crate_dir.rs index 7bbf133bfc..eab1ed5a1d 100644 --- a/module/move/willbe/src/entity/files/crate_dir.rs +++ b/module/move/willbe/src/entity/files/crate_dir.rs @@ -56,7 +56,7 @@ impl CrateDir impl fmt::Display for CrateDir { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { write!( f, "{}", self.0.display() ) } @@ -64,7 +64,7 @@ impl fmt::Display for CrateDir impl fmt::Debug for CrateDir { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { write!( f, "crate dir :: {}", self.0.display() ) } diff --git a/module/move/willbe/src/entity/files/either.rs b/module/move/willbe/src/entity/files/either.rs index 0caa927f4f..d6c2dbb2cb 100644 --- a/module/move/willbe/src/entity/files/either.rs +++ b/module/move/willbe/src/entity/files/either.rs @@ -8,10 +8,7 @@ use core:: DerefMut, }, }; -use std:: -{ - path::Path, -}; +use std::path::Path; // use error:: // { // Result, diff --git a/module/move/willbe/src/entity/files/manifest_file.rs b/module/move/willbe/src/entity/files/manifest_file.rs index 149b50a365..cb6286647c 100644 --- a/module/move/willbe/src/entity/files/manifest_file.rs +++ b/module/move/willbe/src/entity/files/manifest_file.rs @@ -63,7 +63,7 @@ impl ManifestFile impl fmt::Display for ManifestFile { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { write!( f, "{}", self.0.display() ) } @@ -71,7 +71,7 @@ impl fmt::Display for ManifestFile impl fmt::Debug for ManifestFile { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { write!( f, "manifest file :: {}", self.0.display() ) } diff --git a/module/move/willbe/src/entity/files/source_file.rs b/module/move/willbe/src/entity/files/source_file.rs index 630f434006..6e9d9260fe 100644 --- a/module/move/willbe/src/entity/files/source_file.rs +++ b/module/move/willbe/src/entity/files/source_file.rs @@ -49,7 +49,7 @@ impl SourceFile impl fmt::Display for SourceFile { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { write!( f, "{}", self.0.display() ) } @@ -57,7 +57,7 @@ impl fmt::Display for SourceFile impl fmt::Debug for SourceFile { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { write!( f, "source file :: {}", self.0.display() ) } diff --git a/module/move/willbe/src/entity/git.rs b/module/move/willbe/src/entity/git.rs index 00ba0d6b2f..7cb60d449f 100644 --- a/module/move/willbe/src/entity/git.rs +++ b/module/move/willbe/src/entity/git.rs @@ -25,7 +25,7 @@ mod private impl fmt::Display for ExtendedGitReport { - fn fmt( &self, f : &mut fmt::Formatter<'_> ) -> fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> fmt::Result { let Self { add, commit, push } = &self; diff --git a/module/move/willbe/src/entity/package.rs b/module/move/willbe/src/entity/package.rs index 4c5e3cd3e8..f1be725d77 100644 --- a/module/move/willbe/src/entity/package.rs +++ b/module/move/willbe/src/entity/package.rs @@ -3,12 +3,7 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - - use std:: - { - hash::Hash, - }; - + use std::hash::Hash; use crates_tools::CrateArchive; use error:: { diff --git a/module/move/willbe/src/entity/package_md_extension.rs b/module/move/willbe/src/entity/package_md_extension.rs index ab31564b83..14ab13f3c5 100644 --- a/module/move/willbe/src/entity/package_md_extension.rs +++ b/module/move/willbe/src/entity/package_md_extension.rs @@ -160,7 +160,7 @@ mod private data[ "package" ] .get( "metadata" ) } - package::Package::WorkspacePackageRef(_) => + package::Package::WorkspacePackageRef( _ ) => { None } diff --git a/module/move/willbe/src/entity/packages.rs b/module/move/willbe/src/entity/packages.rs index 5525c8a99d..6f83996f3c 100644 --- a/module/move/willbe/src/entity/packages.rs +++ b/module/move/willbe/src/entity/packages.rs @@ -3,10 +3,7 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - use std:: - { - fmt::Formatter, - }; + use std::fmt::Formatter; use package::PackageName; use collection::{ HashMap, HashSet }; diff --git a/module/move/willbe/src/entity/packed_crate.rs b/module/move/willbe/src/entity/packed_crate.rs index 1cd95c7097..1cb55a3ac1 100644 --- a/module/move/willbe/src/entity/packed_crate.rs +++ b/module/move/willbe/src/entity/packed_crate.rs @@ -3,7 +3,6 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - use std:: { io::Read, diff --git a/module/move/willbe/src/entity/progress_bar.rs b/module/move/willbe/src/entity/progress_bar.rs index db61b1f078..5f231ad703 100644 --- a/module/move/willbe/src/entity/progress_bar.rs +++ b/module/move/willbe/src/entity/progress_bar.rs @@ -24,7 +24,7 @@ mod private fn fmt( &self, f : &mut std::fmt::Formatter< '_ > ) -> std::fmt::Result { f.debug_struct( "ProgressBar" ) - .finish() + .finish() } } diff --git a/module/move/willbe/src/entity/publish.rs b/module/move/willbe/src/entity/publish.rs index 93af0e97fc..47af2f9440 100644 --- a/module/move/willbe/src/entity/publish.rs +++ b/module/move/willbe/src/entity/publish.rs @@ -84,7 +84,7 @@ mod private Some( entity::git::GitOptions { git_root : workspace_root, - items : dependencies.iter().chain([ &crate_dir ]).map( | d | d.clone().absolute_path().join( "Cargo.toml" ) ).collect(), + items : dependencies.iter().chain( [ &crate_dir ] ).map( | d | d.clone().absolute_path().join( "Cargo.toml" ) ).collect(), message : format!( "{}-v{}", self.package.name().unwrap(), new_version ), dry : self.dry, }) @@ -184,17 +184,17 @@ mod private action::list::ListOptions::former() .path_to_manifest( wanted.clone() ) .format( action::list::ListFormat::Tree ) - .dependency_sources([ action::list::DependencySource::Local ]) - .dependency_categories([ action::list::DependencyCategory::Primary ]) + .dependency_sources( [ action::list::DependencySource::Local ] ) + .dependency_categories( [ action::list::DependencyCategory::Primary ] ) .form() ) - .map_err( |( _, _e )| fmt::Error )?; + .map_err( | ( _, _e ) | fmt::Error )?; let action::list::ListReport::Tree( list ) = list else { unreachable!() }; #[ allow( clippy::items_after_statements ) ] fn callback( name_bump_report : &collection::HashMap< &String, ( String, String ) >, mut r : tool::ListNodeReport ) -> tool::ListNodeReport { - if let Some(( old, new )) = name_bump_report.get( &r.name ) + if let Some( ( old, new ) ) = name_bump_report.get( &r.name ) { r.version = Some( format!( "({old} -> {new})" ) ); } @@ -409,9 +409,12 @@ mod private Err( e ) => { version::revert( &bump_report ) - .map_err( | le | format_err!( "Base error:\n{}\nRevert error:\n{}", e.to_string().replace( '\n', "\n\t" ), le.to_string().replace( '\n', "\n\t" ) ) ) + .map_err( | le | format_err! + ( + "Base error:\n{}\nRevert error:\n{}", e.to_string().replace( '\n', "\n\t" ), le.to_string().replace( '\n', "\n\t" ) + )) .err_with_report( &report )?; - return Err(( report, e )); + return Err( ( report, e ) ); } }; report.add = git.add; @@ -432,7 +435,7 @@ mod private ) .err_with_report( &report )?; } - return Err(( report, e )); + return Err( ( report, e ) ); } }; @@ -463,7 +466,11 @@ mod private let mut report = vec![]; for package in plan.plans { - let res = perform_package_publish( package ).map_err( |( current_rep, e )| format_err!( "{}\n{current_rep}\n{e}", report.iter().map( | r | format!( "{r}" ) ).join( "\n" ) ) )?; + let res = perform_package_publish( package ).map_err + ( + | ( current_rep, e ) | + format_err!( "{}\n{current_rep}\n{e}", report.iter().map( | r | format!( "{r}" ) ).join( "\n" ) ) + )?; report.push( res ); } diff --git a/module/move/willbe/src/entity/test.rs b/module/move/willbe/src/entity/test.rs index 4ec5fe190d..8bf4156ea3 100644 --- a/module/move/willbe/src/entity/test.rs +++ b/module/move/willbe/src/entity/test.rs @@ -143,7 +143,7 @@ mod private impl fmt::Display for TestPackagePlan { - fn fmt( &self, f : &mut fmt::Formatter< '_ >) -> std::fmt::Result + fn fmt( &self, f : &mut fmt::Formatter< '_ > ) -> std::fmt::Result { writeln!( f, "Package : {}\nThe tests will be executed using the following configurations :", self.crate_dir.clone().absolute_path() )?; let mut all_features = collection::BTreeSet::new(); @@ -186,7 +186,7 @@ mod private row.add_cell( &variant.optimization.to_string() ); let counter = 0; let flag = true; - generate_features_cells(&mut ff, variant, &mut row, counter, flag, &self.enabled_features ); + generate_features_cells( &mut ff, variant, &mut row, counter, flag, &self.enabled_features ); table.add_row( row ); } @@ -365,7 +365,11 @@ mod private .chain( if self.with_all_features { Some( "--all-features".into() ) } else { None } ) // aaa : for Petro : bad, --all-features is always disabled! // aaa : add `debug_assert!( !self.with_all_features )` - .chain( if self.enable_features.is_empty() { None } else { Some([ "--features".into(), self.enable_features.iter().join( "," ) ]) }.into_iter().flatten() ) + .chain( if self.enable_features.is_empty() { None } + else + { + Some( [ "--features".into(), self.enable_features.iter().join( "," ) ] ) + }.into_iter().flatten() ) .chain( self.temp_directory_path.clone().map( | p | vec![ "--target-dir".to_string(), p.to_string_lossy().into() ] ).into_iter().flatten() ) .collect() } @@ -410,7 +414,11 @@ mod private } else { - let envs = if options.backtrace { [( "RUST_BACKTRACE".to_string(), "full".to_string() )].into_iter().collect() } else { collection::HashMap::new() }; + let envs = if options.backtrace + { + [ ( "RUST_BACKTRACE".to_string(), "full".to_string() ) ].into_iter().collect() + } + else { collection::HashMap::new() }; Run::former() .bin_path( program ) .args( args.into_iter().map( std::ffi::OsString::from ).collect::< Vec< _ > >() ) @@ -514,7 +522,7 @@ mod private } all_features.extend( features ); } - let mut ff: Vec< _ > = self.enabled_features.iter().cloned().collect(); + let mut ff : Vec< _ > = self.enabled_features.iter().cloned().collect(); for feature in all_features { if !ff.contains( &feature ) @@ -777,7 +785,7 @@ mod private { report.lock().unwrap().success_reports.push( r ); } - Err(( r, _ )) => + Err( ( r, _ ) ) => { report.lock().unwrap().failure_reports.push( r ); } @@ -794,7 +802,7 @@ mod private } else { - Err(( report, format_err!( "Some tests was failed" ).into() )) + Err( ( report, format_err!( "Some tests was failed" ).into() ) ) } } } diff --git a/module/move/willbe/src/entity/version.rs b/module/move/willbe/src/entity/version.rs index 085b7494ee..f6260bbeac 100644 --- a/module/move/willbe/src/entity/version.rs +++ b/module/move/willbe/src/entity/version.rs @@ -207,7 +207,11 @@ mod private let current_version = version::Version::try_from( package_version.as_str() ).map_err( | e | format_err!( "{report:?}\n{e:#?}" ) )?; if current_version > o.new_version { - return Err( format_err!( "{report:?}\nThe current version of the package is higher than need to be set\n\tpackage: {name}\n\tcurrent_version: {current_version}\n\tnew_version: {}", o.new_version ) ); + return Err( format_err! + ( + "{report:?}\nThe current version of the package is higher than need to be set\n\tpackage: {name}\n\tcurrent_version: {current_version}\n\tnew_version: {}", + o.new_version + )); } report.old_version = Some( o.old_version.to_string() ); report.new_version = Some( o.new_version.to_string() ); @@ -284,12 +288,26 @@ mod private let version = &mut dependency[ "version" ]; if let Some( current_version ) = current_version.strip_prefix( '~' ) { - if current_version != new_version { return Err( format_err!( "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", version.as_str().unwrap_or_default() ) ); } + if current_version != new_version + { + return Err( format_err! + ( + "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", + version.as_str().unwrap_or_default() + )); + } *version = value( format!( "~{old_version}" ) ); } else { - if version.as_str().unwrap() != new_version { return Err( format_err!( "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", version.as_str().unwrap_or_default() ) ); } + if version.as_str().unwrap() != new_version + { + return Err( format_err! + ( + "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", + version.as_str().unwrap_or_default() + )); + } *version = value( old_version.clone() ); } } @@ -311,7 +329,14 @@ mod private if package.get_mut( "name" ).unwrap().as_str().unwrap() == name { let version = &mut package[ "version" ]; - if version.as_str().unwrap() != new_version { return Err( format_err!( "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", version.as_str().unwrap_or_default() ) ); } + if version.as_str().unwrap() != new_version + { + return Err( format_err! + ( + "The current version of the package does not match the expected one. Expected: `{new_version}` Current: `{}`", + version.as_str().unwrap_or_default() + )); + } *version = value( old_version.clone() ); } else diff --git a/module/move/willbe/src/entity/workspace.rs b/module/move/willbe/src/entity/workspace.rs index 945e70ba23..0af932ec27 100644 --- a/module/move/willbe/src/entity/workspace.rs +++ b/module/move/willbe/src/entity/workspace.rs @@ -3,12 +3,10 @@ mod private { #[ allow( clippy::wildcard_imports ) ] use crate::*; - // qqq : for Bohdan : bad // use std::*; - use std::slice; - use former::{ Former }; + use former::Former; /// Stores information about the current workspace. #[ derive( Debug, Clone ) ] diff --git a/module/move/willbe/src/tool/cargo.rs b/module/move/willbe/src/tool/cargo.rs index a8f926860a..1dd5ef240d 100644 --- a/module/move/willbe/src/tool/cargo.rs +++ b/module/move/willbe/src/tool/cargo.rs @@ -162,7 +162,8 @@ mod private file.store()?; Some( manifest ) - } else { None }; + } + else { None }; let ( program, options ) = ( "rustup", args.to_pack_args() ); if args.dry @@ -240,7 +241,8 @@ mod private file.store()?; Some( manifest ) - } else { None }; + } + else { None }; let ( program, arguments) = ( "cargo", args.as_publish_args() ); if args.dry @@ -276,7 +278,16 @@ mod private } if args.retry_count > 0 { - Err( error::untyped::format_err!( "It took {} attempts, but still failed. Here are the errors:\n{}", args.retry_count + 1, results.into_iter().map( | r | format!( "- {r}" ) ).collect::< Vec< _ > >().join( "\n" ) ) ) + Err( error::untyped::format_err! + ( + "It took {} attempts, but still failed. Here are the errors:\n{}", + args.retry_count + 1, + results + .into_iter() + .map( | r | format!( "- {r}" ) ) + .collect::< Vec< _ > >() + .join( "\n" ) + )) } else { diff --git a/module/move/willbe/src/tool/git.rs b/module/move/willbe/src/tool/git.rs index 27c9743f4d..471d5e5abe 100644 --- a/module/move/willbe/src/tool/git.rs +++ b/module/move/willbe/src/tool/git.rs @@ -25,7 +25,11 @@ mod private /// # Returns : /// Returns a result containing a report indicating the result of the operation. // qqq : should be typed error, apply err_with - #[ cfg_attr( feature = "tracing", tracing::instrument( skip( path, objects ), fields( path = %path.as_ref().display() ) ) ) ] + #[ cfg_attr + ( + feature = "tracing", + tracing::instrument( skip( path, objects ), fields( path = %path.as_ref().display() ) ) + )] pub fn add< P, Os, O >( path : P, objects : Os, dry : bool ) -> error::untyped::Result< Report > // qqq : use typed error @@ -76,7 +80,15 @@ mod private /// # Returns : /// Returns a result containing a report indicating the result of the operation. // qqq : should be typed error, apply err_with - #[ cfg_attr( feature = "tracing", tracing::instrument( skip( path, message ), fields( path = %path.as_ref().display(), message = %message.as_ref() ) ) ) ] + #[ cfg_attr + ( + feature = "tracing", + tracing::instrument + ( + skip( path, message ), + fields( path = %path.as_ref().display(), message = %message.as_ref() ) + ) + )] pub fn commit< P, M >( path : P, message : M, dry : bool ) -> error::untyped::Result< Report > // qqq : don't use 1-prameter Result where diff --git a/module/move/willbe/src/tool/graph.rs b/module/move/willbe/src/tool/graph.rs index e7e06db908..89883cbb8a 100644 --- a/module/move/willbe/src/tool/graph.rs +++ b/module/move/willbe/src/tool/graph.rs @@ -25,10 +25,7 @@ mod private #[ allow( clippy::wildcard_imports ) ] use petgraph::prelude::*; - use error:: - { - typed::Error, - }; + use error::typed::Error; use package::{ Package, publish_need }; // qqq : for Bohdan : bad : tools can't depend on entitties! @@ -54,11 +51,7 @@ mod private #[ must_use ] pub fn construct< PackageIdentifier > ( - packages : &HashMap - < - PackageIdentifier, - HashSet< PackageIdentifier >, - > + packages : &HashMap< PackageIdentifier, HashSet< PackageIdentifier >, > ) -> Graph< &PackageIdentifier, &PackageIdentifier > where