Skip to content

Commit

Permalink
Format tools experiment 4 (#1438)
Browse files Browse the repository at this point in the history
format_tools : output formats
  • Loading branch information
Wandalen authored Aug 29, 2024
1 parent 561499d commit 871ea36
Show file tree
Hide file tree
Showing 274 changed files with 3,402 additions and 1,177 deletions.
2 changes: 1 addition & 1 deletion module/alias/instance_of/src/typing/implements_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
mod implements_impl;

/// Internal namespace.
pub( crate ) mod private
mod private
{

///
Expand Down
2 changes: 1 addition & 1 deletion module/alias/instance_of/src/typing/is_slice_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#![ doc = include_str!( concat!( env!( "CARGO_MANIFEST_DIR" ), "/", "Readme.md" ) ) ]

/// Internal namespace.
pub( crate ) mod private
mod private
{

/// Macro to answer the question: is it a slice?
Expand Down
2 changes: 1 addition & 1 deletion module/alias/wtest_basic/src/test/basic/helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
/// Internal namespace.
pub( crate ) mod private
mod private
{

// zzz : move here test tools
Expand Down
2 changes: 1 addition & 1 deletion module/alias/wtest_basic/src/test/basic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
/// Internal namespace.
pub( crate ) mod private
mod private
{
}

Expand Down
2 changes: 1 addition & 1 deletion module/core/clone_dyn/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub mod dependency

/// Internal namespace.
#[ cfg( feature = "enabled" ) ]
pub( crate ) mod private
mod private
{
}

Expand Down
2 changes: 1 addition & 1 deletion module/core/clone_dyn_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub mod dependency
/// Internal namespace.
// #[ cfg( any( not( feature = "no_std" ), feature = "use_alloc" ) ) ]
#[ cfg( feature = "enabled" ) ]
pub( crate ) mod private
mod private
{

// xxx : ?
Expand Down
4 changes: 2 additions & 2 deletions module/core/collection_tools/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ assert_eq!( meta_set, std_set );
# }
```

Another example with `list!`:
Another example with `llist!`:

```rust
# #[ cfg( all( feature = "enabled", feature = "collection_constructors" ) ) ]
# #[ cfg( any( feature = "use_alloc", not( feature = "no_std" ) ) ) ]
# {
use collection_tools::*;

let meta_list : LinkedList< i32 > = list! { 3, 13 };
let meta_list : LinkedList< i32 > = llist! { 3, 13 };

// this `LinkedList` is just a reexport from `alloc`,
// so it can be used in the same places as `alloc/std::LinkedList`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ pub mod hmap;
/// [std::collections::HashSet] macros
pub mod hset;
/// [std::collections::LinkedList] macros
pub mod list;
pub mod llist;
/// [Vec] macros
pub mod vec;
/// [std::collections::VecDeque] macros
pub mod vecd;
pub mod deque;
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ pub use alloc::collections::vec_deque::*;

/// Creates a `VecDeque` from a list of elements.
///
/// The `vecd` macro allows for the convenient creation of a `VecDeque` with initial elements.
/// The `deque` macro allows for the convenient creation of a `VecDeque` with initial elements.
/// Elements passed to the macro are automatically converted into the deque's element type
/// using `.into()`, enabling the use of literals or values of different, but convertible types.
///
/// Note: The `vecd` macro relies on the `.into()` method to convert each element into the target type
/// Note: The `deque` macro relies on the `.into()` method to convert each element into the target type
/// of the `VecDeque`. This means that the elements must be compatible with the `Into<T>` trait for the
/// type `T` used in the `VecDeque`.
///
Expand All @@ -21,15 +21,15 @@ pub use alloc::collections::vec_deque::*;
/// The macro can be called with a comma-separated list of elements. A trailing comma is optional.
///
/// ```rust
/// # use collection_tools::{ VecDeque, vecd };
/// # use collection_tools::{ VecDeque, deque };
/// // VecDeque of i32
/// let vd1 = vecd!( 1, 2, 3, 4, 5 );
/// let vd1 = deque!( 1, 2, 3, 4, 5 );
///
/// // VecDeque of String
/// let vd2 = vecd!{ "hello", "world", "rust" };
/// let vd2 = deque!{ "hello", "world", "rust" };
///
/// // With trailing comma
/// let vd3 = vecd!( 1.1, 2.2, 3.3, );
/// let vd3 = deque!( 1.1, 2.2, 3.3, );
/// ```
///
/// # Parameters
Expand All @@ -48,8 +48,8 @@ pub use alloc::collections::vec_deque::*;
/// Basic usage with integers:
///
/// ```rust
/// # use collection_tools::{ VecDeque, vecd };
/// let vd : VecDeque< i32 > = vecd!( 1, 2, 3 );
/// # use collection_tools::{ VecDeque, deque };
/// let vd : VecDeque< i32 > = deque!( 1, 2, 3 );
/// assert_eq!( vd.front(), Some( &1 ) ); // The first element is 1
/// assert_eq!( vd.back(), Some( &3 ) ); // The last element is 3
/// ```
Expand All @@ -59,23 +59,23 @@ pub use alloc::collections::vec_deque::*;
/// Creating a `VecDeque` of `&str` from string literals:
///
/// ```rust
/// # use collection_tools::{ VecDeque, vecd };
/// let fruits = vecd!{ "apple", "banana", "cherry" };
/// # use collection_tools::{ VecDeque, deque };
/// let fruits = deque!{ "apple", "banana", "cherry" };
/// assert_eq!( fruits.front(), Some( &"apple" ) ); // The first element
/// assert_eq!( fruits.back(), Some( &"cherry" ) ); // The last element
/// ```
///
#[ cfg( feature = "collection_constructors" ) ]
#[ macro_export( local_inner_macros ) ]
macro_rules! vecd
macro_rules! deque
{
(
$( $key : expr ),* $( , )?
)
=>
{{
let _cap = count!( @count $( $key ),* );
let mut _vecd = $crate::vecd::VecDeque::with_capacity( _cap );
let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap );
$(
_vecd.push_back( $key );
)*
Expand Down Expand Up @@ -168,7 +168,7 @@ macro_rules! into_vecd
=>
{{
let _cap = count!( @count $( $key ),* );
let mut _vecd = $crate::vecd::VecDeque::with_capacity( _cap );
let mut _vecd = $crate::deque::VecDeque::with_capacity( _cap );
$(
_vecd.push_back( Into::into( $key ) );
)*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,48 @@
#[ allow( unused_imports ) ]
pub use alloc::collections::linked_list::*;

/// Creates a `LinkedList` from a list of elements.
/// Creates a `LinkedList` from a llist of elements.
///
/// The `list` macro facilitates the creation of a `LinkedList` with initial elements.
/// The `llist` macro facilitates the creation of a `LinkedList` with initial elements.
///
/// # Origin
///
/// This collection is reexported from `alloc`.
///
/// # Syntax
///
/// The macro can be called with a comma-separated list of elements. A trailing comma is optional.
/// The macro can be called with a comma-separated llist of elements. A trailing comma is optional.
///
/// ```rust
/// # use collection_tools::{ LinkedList, list };
/// # use collection_tools::{ LinkedList, llist };
/// // LinkedList of i32
/// let lst1 = list!( 1, 2, 3, 4, 5 );
/// let lst1 = llist!( 1, 2, 3, 4, 5 );
///
/// // LinkedList of &str
/// let lst2 = list!{ "hello", "world", "rust" };
/// let lst2 = llist!{ "hello", "world", "rust" };
///
/// // With trailing comma
/// let lst3 = list!( 1.1, 2.2, 3.3, );
/// let lst3 = llist!( 1.1, 2.2, 3.3, );
/// ```
///
/// # Parameters
///
/// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `LinkedList`.
/// - `$( $key:expr ),* $( , )?`: A comma-separated llist of elements to insert into the `LinkedList`.
/// Each element can be of any type that implements the `Into<T>` trait, where `T` is the
/// type stored in the `LinkedList`.
///
/// # Returns
///
/// Returns a `LinkedList` containing all the specified elements. The capacity of the list is
/// Returns a `LinkedList` containing all the specified elements. The capacity of the llist is
/// dynamically adjusted based on the number of elements provided.
///
/// # Example
///
/// Basic usage with integers:
///
/// ```rust
/// # use collection_tools::{ LinkedList, list };
/// let lst = list!( 1, 2, 3 );
/// # use collection_tools::{ LinkedList, llist };
/// let lst = llist!( 1, 2, 3 );
/// assert_eq!( lst.front(), Some( &1 ) ); // The first element is 1
/// assert_eq!( lst.back(), Some( &3 ) ); // The last element is 3
/// ```
Expand All @@ -53,15 +53,15 @@ pub use alloc::collections::linked_list::*;
/// Creating a `LinkedList` of `&str` from string literals:
///
/// ```rust
/// # use collection_tools::{ LinkedList, list };
/// let fruits = list!{ "apple", "banana", "cherry" };
/// # use collection_tools::{ LinkedList, llist };
/// let fruits = llist!{ "apple", "banana", "cherry" };
/// assert_eq!( fruits.front(), Some( &"apple" ) ); // The first element
/// assert_eq!( fruits.back(), Some( &"cherry" ) ); // The last element
/// ```
///
#[ cfg( feature = "collection_constructors" ) ]
#[ macro_export( local_inner_macros ) ]
macro_rules! list
macro_rules! llist
{
(
$( $key : expr ),* $( , )?
Expand All @@ -70,21 +70,21 @@ macro_rules! list
{{
// "The LinkedList allows pushing and popping elements at either end in constant time."
// So no `with_capacity`
let mut _lst = $crate::list::LinkedList::new();
let mut _lst = $crate::llist::LinkedList::new();
$(
_lst.push_back( $key );
)*
_lst
}};
}

/// Creates a `LinkedList` from a list of elements.
/// Creates a `LinkedList` from a llist of elements.
///
/// The `into_list` macro facilitates the creation of a `LinkedList` with initial elements.
/// Elements passed to the macro are automatically converted into the list's element type
/// The `into_llist` macro facilitates the creation of a `LinkedList` with initial elements.
/// Elements passed to the macro are automatically converted into the llist's element type
/// using `.into()`, making it convenient to use literals or values of different, but convertible types.
///
/// Note: The `into_list` macro leverages the `.into()` method to convert each element into the target type
/// Note: The `into_llist` macro leverages the `.into()` method to convert each element into the target type
/// of the `LinkedList`. Therefore, the elements must be compatible with the `Into<T>` trait for the
/// type `T` used in the `LinkedList`. Also, this means that sometimes you must specify the type of collection's items.
///
Expand All @@ -94,38 +94,38 @@ macro_rules! list
///
/// # Syntax
///
/// The macro can be called with a comma-separated list of elements. A trailing comma is optional.
/// The macro can be called with a comma-separated llist of elements. A trailing comma is optional.
///
/// ```rust
/// # use collection_tools::{ LinkedList, into_list };
/// # use collection_tools::{ LinkedList, into_llist };
/// // LinkedList of i32
/// let lst1 : LinkedList< i32 > = into_list!( 1, 2, 3, 4, 5 );
/// let lst1 : LinkedList< i32 > = into_llist!( 1, 2, 3, 4, 5 );
///
/// // LinkedList of String
/// let lst2 : LinkedList< String > = into_list!{ "hello".to_string(), "world", "rust" };
/// let lst2 : LinkedList< String > = into_llist!{ "hello".to_string(), "world", "rust" };
///
/// // With trailing comma
/// let lst3 : LinkedList< f64 > = into_list!( 1.1, 2.2, 3.3, );
/// let lst3 : LinkedList< f64 > = into_llist!( 1.1, 2.2, 3.3, );
/// ```
///
/// # Parameters
///
/// - `$( $key:expr ),* $( , )?`: A comma-separated list of elements to insert into the `LinkedList`.
/// - `$( $key:expr ),* $( , )?`: A comma-separated llist of elements to insert into the `LinkedList`.
/// Each element can be of any type that implements the `Into<T>` trait, where `T` is the
/// type stored in the `LinkedList`.
///
/// # Returns
///
/// Returns a `LinkedList` containing all the specified elements. The capacity of the list is
/// Returns a `LinkedList` containing all the specified elements. The capacity of the llist is
/// dynamically adjusted based on the number of elements provided.
///
/// # Example
///
/// Basic usage with integers:
///
/// ```rust
/// # use collection_tools::{ LinkedList, into_list };
/// let lst: LinkedList< i32 > = into_list!( 1, 2, 3 );
/// # use collection_tools::{ LinkedList, into_llist };
/// let lst: LinkedList< i32 > = into_llist!( 1, 2, 3 );
/// assert_eq!( lst.front(), Some( &1 ) ); // The first element is 1
/// assert_eq!( lst.back(), Some( &3 ) ); // The last element is 3
/// ```
Expand All @@ -135,8 +135,8 @@ macro_rules! list
/// Using with different types that implement `Into<T>`:
///
/// ```rust
/// # use collection_tools::{ LinkedList, into_list };
/// let chars : LinkedList< String > = into_list!( "a", "b", "c" );
/// # use collection_tools::{ LinkedList, into_llist };
/// let chars : LinkedList< String > = into_llist!( "a", "b", "c" );
/// assert!( chars.contains( &"a".to_string() ) );
/// assert!( chars.contains( &"b".to_string() ) );
/// assert!( chars.contains( &"c".to_string() ) );
Expand All @@ -147,15 +147,15 @@ macro_rules! list
/// Creating a `LinkedList` of `String` from string literals:
///
/// ```rust
/// # use collection_tools::{ LinkedList, into_list };
/// let fruits : LinkedList< String > = into_list!{ "apple", "banana", "cherry" };
/// # use collection_tools::{ LinkedList, into_llist };
/// let fruits : LinkedList< String > = into_llist!{ "apple", "banana", "cherry" };
/// assert_eq!( fruits.front(), Some( &"apple".to_string() ) ); // The first element
/// assert_eq!( fruits.back(), Some( &"cherry".to_string() ) ); // The last element
/// ```
///
#[ cfg( feature = "collection_into_constructors" ) ]
#[ macro_export( local_inner_macros ) ]
macro_rules! into_list
macro_rules! into_llist
{
(
$( $key : expr ),* $( , )?
Expand All @@ -164,7 +164,7 @@ macro_rules! into_list
{{
// "The LinkedList allows pushing and popping elements at either end in constant time."
// So no `with_capacity`
let mut _lst = $crate::list::LinkedList::new();
let mut _lst = $crate::llist::LinkedList::new();
$(
_lst.push_back( Into::into( $key ) );
)*
Expand Down
Loading

0 comments on commit 871ea36

Please sign in to comment.