Skip to content

Commit

Permalink
Updating paste macro usage (#3334)
Browse files Browse the repository at this point in the history
  • Loading branch information
wdanilo authored Mar 22, 2022
1 parent a87b202 commit ccaf248
Show file tree
Hide file tree
Showing 14 changed files with 19 additions and 21 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/rust/ensogl/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ js-sys = { version = "0.3.28" }
nalgebra = { version = "0.26.1" }
num_enum = { version = "0.5.1" }
num-traits = { version = "0.2" }
paste = { version = "1.0.5" }
rustc-hash = { version = "1.0.1" }
shrinkwraprs = { version = "0.3.0" }
smallvec = { version = "1.0.0" }
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/ensogl/core/src/animation/easing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait CloneableFnEasing = 'static + Clone + Fn(f32) -> f32;

macro_rules! define_in_out_easing_fn {
(fn $tname:ident $name:ident $lambda:expr) => {
paste::item! {
paste! {
/// A $name-in function type.
pub type [<$tname In>] = impl Clone + Fn(f32) -> f32;
/// A $name-out function type.
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/ensogl/core/src/data/function/closure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ macro_rules! closure {
($($larg:ident : $larg_type:ty),*)
-> $type:ident
$body:tt
) => { paste::item! {
) => { paste! {
#[cfg(not(feature = "no_unboxed_callbacks"))]
/// Closure type.
pub type $type<$($param),*> =
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/ensogl/core/src/debug/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ macro_rules! emit_if_integer {
/// Emits the StatsData struct, and extends StatsWithTimeProvider with accessors to StatsData
/// fields.
macro_rules! gen_stats {
($($field:ident : $field_type:ty),* $(,)?) => { paste::item! {
($($field:ident : $field_type:ty),* $(,)?) => { paste! {


// === StatsData ===
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/ensogl/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! The core vector rendering engine for EnsoGL, a blazing fast 2D drawing library. This crate
//! contains the core utilities necessary for the rendering engine to run correctly. See thr docs
//! contains the core utilities necessary for the rendering engine to run correctly. See the docs
//! of the `ensogl` crate to learn more.
#![recursion_limit = "512"]
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/ensogl/core/src/system/gpu/data/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ use enum_dispatch::*;
pub struct BadVariant;

macro_rules! define_any_buffer {
([] [$([$base:ident $param:ident])*]) => { paste::item! {
([] [$([$base:ident $param:ident])*]) => { paste! {

/// An enum with a variant per possible buffer type (i32, f32, Vector<f32>,
/// and many, many more). It provides a faster alternative to dyn trait one:
Expand Down
4 changes: 2 additions & 2 deletions lib/rust/ensogl/core/src/system/gpu/data/uniform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<T> WithContent for Uniform<T> {
pub struct TypeMismatch;

macro_rules! define_any_prim_uniform {
( [] [$([$t1:ident $t2:ident])*] ) => { paste::item! {
( [] [$([$t1:ident $t2:ident])*] ) => { paste! {
/// Existentially typed uniform value.
#[allow(non_camel_case_types)]
#[enum_dispatch(AnyPrimUniformOps)]
Expand Down Expand Up @@ -285,7 +285,7 @@ impl<Value: UniformUpload> AnyPrimUniformOps for UniformData<Value> {
// =========================

macro_rules! define_any_texture_uniform {
( [ $([$storage:ident $internal_format:ident $item_type:ident])* ] ) => { paste::item! {
( [ $([$storage:ident $internal_format:ident $item_type:ident])* ] ) => { paste! {
#[allow(non_camel_case_types)]
#[derive(Clone,CloneRef,Debug)]
pub enum AnyTextureUniform {
Expand Down
6 changes: 3 additions & 3 deletions lib/rust/ensogl/example/easing-animator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,9 @@ macro_rules! examples {
($($name:ident),*) => {$(
std::mem::forget(Example::new(
stringify!($name),
paste::expr!{[<$name _in>]()},
paste::expr!{[<$name _out>]()},
paste::expr!{[<$name _in_out>]()},
paste!{[<$name _in>]()},
paste!{[<$name _out>]()},
paste!{[<$name _in_out>]()},
));
)*};
}
Expand Down
4 changes: 2 additions & 2 deletions lib/rust/logger/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,13 @@ macro_rules! define_global_processor {
/// Global processor definition.
#[derive(Copy, Clone, Debug, Default)]
pub struct $name;
paste::item! {
paste! {
#[allow(non_upper_case_globals)]
static mut [<$name _STATIC_MUT>]: Option<$tp> = None;
}
impl GlobalProcessor for $name {
type Processor = $tp;
paste::item! {
paste! {
#[allow(unsafe_code)]
fn get_mut() -> &'static mut Self::Processor {
unsafe {
Expand Down
6 changes: 3 additions & 3 deletions lib/rust/optics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ impl<T> HasLens for T {}

macro_rules! mk_lens_field_decl {
($struct_name:ident<$($param:ident),*>{$field_name:ident : $field_type:ty}) => {
paste::item! {
paste! {
// struct FIELD_bar;
struct [<FIELD_ $field_name>];

Expand All @@ -336,7 +336,7 @@ paste::item! {

macro_rules! mk_lenses_for {
($struct_name:ident<$($param:ident),*>{$field_name:ident : $field_type:ty}) => {
paste::item! {
paste! {

mk_lens_field_decl!($struct_name<$($param),*>{$field_name:$field_type});

Expand Down Expand Up @@ -423,7 +423,7 @@ paste::item! {
}};

($struct_name:ident<$($param:ident),*> :: $cons_name:ident {$field_name:ident : $field_type:ty}) => {
paste::item! {
paste! {

mk_lens_field_decl!($struct_name<$($param),*>{$field_name:$field_type});

Expand Down
2 changes: 1 addition & 1 deletion lib/rust/prelude/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ itertools = "0.10.0"
lazy_static = "1.4"
num = "0.4.0"
object = { version = "0.24.0" }
paste = "1.0.5"
paste = "1.0"
shrinkwraprs = "0.3.0"
serde = { version = "1.0.126", features = ["derive", "rc"], optional = true }
serde_json = { version = "1.0", optional = true }
Expand Down
4 changes: 2 additions & 2 deletions lib/rust/prelude/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub use ifmt::*;
pub use itertools::Itertools;
pub use lazy_static::lazy_static;
pub use num::Num;
pub use paste;
pub use paste::paste;
pub use shrinkwraprs::Shrinkwrap;
pub use weak_table;
pub use weak_table::traits::WeakElement;
Expand Down Expand Up @@ -190,7 +190,7 @@ where
#[macro_export]
macro_rules! clone_boxed {
( $name:ident ) => {
paste::item! {
paste! {
#[allow(missing_docs)]
pub trait [<CloneBoxedFor $name>] {
fn clone_boxed(&self) -> Box<dyn $name>;
Expand Down
2 changes: 1 addition & 1 deletion lib/rust/shapely/src/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ macro_rules! shared_struct {
}
}

paste::item! {
paste! {
$(#[$($meta)*])*
#[derive(CloneRef)]
pub struct [<Weak $name>] <$($params)*> { weak: Weak<RefCell<$name_mut<$($params)*>>> }
Expand Down

0 comments on commit ccaf248

Please sign in to comment.