From cfaf87fb99fb0c0013b2b3b1e2f4c825cd5d49aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Sat, 18 Jun 2022 21:14:51 +0200 Subject: [PATCH 1/2] 1.61 const update --- src/number.rs | 4 +- src/simulation/monte_carlo/heat_bath.rs | 5 +- src/simulation/monte_carlo/hybrid.rs | 9 ++-- .../monte_carlo/hybrid_monte_carlo.rs | 46 ++++++++++--------- .../monte_carlo/metropolis_hastings.rs | 9 ++-- .../monte_carlo/metropolis_hastings_sweep.rs | 7 +-- src/simulation/monte_carlo/mod.rs | 7 +-- src/simulation/state.rs | 7 +-- src/statistics/distribution.rs | 6 +-- 9 files changed, 54 insertions(+), 46 deletions(-) diff --git a/src/number.rs b/src/number.rs index 9ab3d851..b7c71956 100644 --- a/src/number.rs +++ b/src/number.rs @@ -19,12 +19,12 @@ where D: num_traits::sign::Unsigned + std::cmp::Ord + Copy, { /// Get tje integer part of the number - pub fn integer(&self) -> I { + pub const fn integer(&self) -> I { self.integer } /// Get the decimal part of the number as it is stored (as raw data) - pub fn decimal(&self) -> D { + pub const fn decimal(&self) -> D { self.decimal } } diff --git a/src/simulation/monte_carlo/heat_bath.rs b/src/simulation/monte_carlo/heat_bath.rs index cf9ba2c0..bde56480 100644 --- a/src/simulation/monte_carlo/heat_bath.rs +++ b/src/simulation/monte_carlo/heat_bath.rs @@ -48,11 +48,12 @@ pub struct HeatBathSweep { impl HeatBathSweep { /// Create a new Self form a rng. - pub fn new(rng: Rng) -> Self { + pub const fn new(rng: Rng) -> Self { Self { rng } } /// Absorbed self and return the RNG as owned. It essentially deconstruct the structure. + #[allow(clippy::missing_const_for_fn)] // false positive pub fn rng_owned(self) -> Rng { self.rng } @@ -63,7 +64,7 @@ impl HeatBathSweep { } /// Get a reference to the rng. - pub fn rng(&self) -> &Rng { + pub const fn rng(&self) -> &Rng { &self.rng } diff --git a/src/simulation/monte_carlo/hybrid.rs b/src/simulation/monte_carlo/hybrid.rs index 7f35a7ff..cf8c3f5e 100644 --- a/src/simulation/monte_carlo/hybrid.rs +++ b/src/simulation/monte_carlo/hybrid.rs @@ -103,7 +103,7 @@ where } /// Getter for the reference hold by self. - pub fn data(&self) -> &MC { + pub const fn data(&self) -> &MC { self.data } } @@ -344,20 +344,20 @@ where { getter!( /// get the first method - pub, + pub const, method_1, MC1 ); getter!( /// get the second method - pub, + pub const, method_2, MC2 ); /// Create a new Self from two methods - pub fn new(method_1: MC1, method_2: MC2) -> Self { + pub const fn new(method_1: MC1, method_2: MC2) -> Self { Self { method_1, method_2, @@ -366,6 +366,7 @@ where } /// Deconstruct the structure ang gives back both methods + #[allow(clippy::missing_const_for_fn)] // false positive pub fn deconstruct(self) -> (MC1, MC2) { (self.method_1, self.method_2) } diff --git a/src/simulation/monte_carlo/hybrid_monte_carlo.rs b/src/simulation/monte_carlo/hybrid_monte_carlo.rs index 51328460..fe4942c2 100644 --- a/src/simulation/monte_carlo/hybrid_monte_carlo.rs +++ b/src/simulation/monte_carlo/hybrid_monte_carlo.rs @@ -89,12 +89,12 @@ where { getter!( /// Get a ref to the rng. - pub rng() -> Rng + pub const rng() -> Rng ); project!( /// Get the integrator. - pub internal.integrator() -> &I + pub const internal.integrator() -> &I ); project_mut!( @@ -104,12 +104,12 @@ where project!( /// Get `delta_t`. - pub internal.delta_t() -> Real + pub const internal.delta_t() -> Real ); project!( /// Get the number of steps. - pub internal.number_of_steps() -> usize + pub const internal.number_of_steps() -> usize ); /// gives the following parameter for the HCM : @@ -117,7 +117,7 @@ where /// - number_of_steps is the number of time /// - integrator is the methods to solve the equation of motion /// - rng, a random number generator - pub fn new(delta_t: Real, number_of_steps: usize, integrator: I, rng: Rng) -> Self { + pub const fn new(delta_t: Real, number_of_steps: usize, integrator: I, rng: Rng) -> Self { Self { internal: HybridMonteCarloInternal::, I, D>::new( delta_t, @@ -134,6 +134,7 @@ where } /// Get the last probably of acceptance of the random change. + #[allow(clippy::missing_const_for_fn)] // false positive pub fn rng_owned(self) -> Rng { self.rng } @@ -219,27 +220,27 @@ where { getter!( /// Get the integrator. - pub, + pub const, integrator, I ); getter_copy!( /// Get `delta_t`. - pub, + pub const, delta_t, Real ); getter_copy!( /// Get the number of steps. - pub, + pub const, number_of_steps, usize ); /// see [HybridMonteCarlo::new] - pub fn new(delta_t: Real, number_of_steps: usize, integrator: I) -> Self { + pub const fn new(delta_t: Real, number_of_steps: usize, integrator: I) -> Self { Self { delta_t, number_of_steps, @@ -340,14 +341,14 @@ where { getter!( /// Get a ref to the rng. - pub, + pub const, rng, Rng ); project!( /// Get the integrator. - pub, + pub const, integrator, internal, &I @@ -363,7 +364,7 @@ where project!( /// Get `delta_t`. - pub, + pub const, delta_t, internal, Real @@ -371,7 +372,7 @@ where project!( /// Get the number of steps. - pub, + pub const, number_of_steps, internal, usize @@ -382,7 +383,7 @@ where /// - number_of_steps is the number of time /// - integrator is the method to solve the equation of motion /// - rng, a random number generator - pub fn new(delta_t: Real, number_of_steps: usize, integrator: I, rng: Rng) -> Self { + pub const fn new(delta_t: Real, number_of_steps: usize, integrator: I, rng: Rng) -> Self { Self { internal: HybridMonteCarloInternalDiagnostics::< LatticeStateEFSyncDefault, @@ -399,16 +400,17 @@ where } /// Get the last probably of acceptance of the random change. - pub fn prob_replace_last(&self) -> Real { + pub const fn prob_replace_last(&self) -> Real { self.internal.prob_replace_last() } /// Get if last step has accepted the replacement. - pub fn has_replace_last(&self) -> bool { + pub const fn has_replace_last(&self) -> bool { self.internal.has_replace_last() } /// Get the last probably of acceptance of the random change. + #[allow(clippy::missing_const_for_fn)] // false positive pub fn rng_owned(self) -> Rng { self.rng } @@ -493,27 +495,27 @@ where { getter!( /// Get the integrator. - pub, + pub const, integrator, I ); getter_copy!( /// Get `delta_t`. - pub, + pub const, delta_t, Real ); getter_copy!( /// Get the number of steps. - pub, + pub const, number_of_steps, usize ); /// see [HybridMonteCarlo::new] - pub fn new(delta_t: Real, number_of_steps: usize, integrator: I) -> Self { + pub const fn new(delta_t: Real, number_of_steps: usize, integrator: I) -> Self { Self { delta_t, number_of_steps, @@ -525,12 +527,12 @@ where } /// Get the last probably of acceptance of the random change. - pub fn prob_replace_last(&self) -> Real { + pub const fn prob_replace_last(&self) -> Real { self.prob_replace_last } /// Get if last step has accepted the replacement. - pub fn has_replace_last(&self) -> bool { + pub const fn has_replace_last(&self) -> bool { self.has_replace_last } diff --git a/src/simulation/monte_carlo/metropolis_hastings.rs b/src/simulation/monte_carlo/metropolis_hastings.rs index d2efae19..e304e844 100644 --- a/src/simulation/monte_carlo/metropolis_hastings.rs +++ b/src/simulation/monte_carlo/metropolis_hastings.rs @@ -303,28 +303,28 @@ pub struct MetropolisHastingsDeltaDiagnostic { impl MetropolisHastingsDeltaDiagnostic { getter_copy!( /// Get the last probably of acceptance of the random change. - pub, + pub const, prob_replace_last, Real ); getter_copy!( /// Get if last step has accepted the replacement. - pub, + pub const, has_replace_last, bool ); getter!( /// Get a ref to the rng. - pub, + pub const, rng, Rng ); getter_copy!( /// Get the spread parameter. - pub spread() -> Real + pub const spread() -> Real ); /// Get a mutable reference to the rng. @@ -351,6 +351,7 @@ impl MetropolisHastingsDeltaDiagnostic { } /// Absorbs self and return the RNG as owned. It essentially deconstruct the structure. + #[allow(clippy::missing_const_for_fn)] // false positive pub fn rng_owned(self) -> Rng { self.rng } diff --git a/src/simulation/monte_carlo/metropolis_hastings_sweep.rs b/src/simulation/monte_carlo/metropolis_hastings_sweep.rs index 0c8af6f6..c73e99b1 100644 --- a/src/simulation/monte_carlo/metropolis_hastings_sweep.rs +++ b/src/simulation/monte_carlo/metropolis_hastings_sweep.rs @@ -63,7 +63,7 @@ pub struct MetropolisHastingsSweep { impl MetropolisHastingsSweep { getter!( /// Get a ref to the rng. - pub, + pub const, rng, Rng ); @@ -88,16 +88,17 @@ impl MetropolisHastingsSweep { } /// Get the mean of last probably of acceptance of the random change. - pub fn prob_replace_mean(&self) -> Real { + pub const fn prob_replace_mean(&self) -> Real { self.prob_replace_mean } /// Number of accepted change during last sweep - pub fn number_replace_last(&self) -> usize { + pub const fn number_replace_last(&self) -> usize { self.number_replace_last } /// Get the last probably of acceptance of the random change. + #[allow(clippy::missing_const_for_fn)] // false positive pub fn rng_owned(self) -> Rng { self.rng } diff --git a/src/simulation/monte_carlo/mod.rs b/src/simulation/monte_carlo/mod.rs index 3cadb423..250fc641 100644 --- a/src/simulation/monte_carlo/mod.rs +++ b/src/simulation/monte_carlo/mod.rs @@ -226,13 +226,13 @@ where { getter!( /// Get a ref to the rng. - pub, + pub const, rng, Rng ); /// Create the wrapper. - pub fn new(mcd: MCD, rng: Rng) -> Self { + pub const fn new(mcd: MCD, rng: Rng) -> Self { Self { mcd, rng, @@ -241,12 +241,13 @@ where } /// deconstruct the structure to get back the rng if necessary + #[allow(clippy::missing_const_for_fn)] // false positive pub fn deconstruct(self) -> (MCD, Rng) { (self.mcd, self.rng) } /// Get a reference to the [`MonteCarloDefault`] inside the wrapper. - pub fn mcd(&self) -> &MCD { + pub const fn mcd(&self) -> &MCD { &self.mcd } diff --git a/src/simulation/state.rs b/src/simulation/state.rs index 384a4597..f32e2fdb 100644 --- a/src/simulation/state.rs +++ b/src/simulation/state.rs @@ -866,7 +866,7 @@ where { getter!( /// get a reference to the state - pub, + pub const, state, State ); @@ -874,7 +874,7 @@ where /// Create a new SimulationStateLeap directly from a state without applying any modification. /// /// In most cases wou will prefer to build it using [`LatticeStateNew`] or [`Self::from_synchronous`]. - pub fn new_from_state(state: State) -> Self { + pub const fn new_from_state(state: State) -> Self { Self { state } } @@ -1067,6 +1067,7 @@ where { /// Absorbs self and return the state as owned. /// It essentially deconstruct the structure. + #[allow(clippy::missing_const_for_fn)] // false positive pub fn state_owned(self) -> State where State: Sized, @@ -1075,7 +1076,7 @@ where } /// Get a reference to the state. - pub fn lattice_state(&self) -> &State { + pub const fn lattice_state(&self) -> &State { &self.lattice_state } diff --git a/src/statistics/distribution.rs b/src/statistics/distribution.rs index 9763413b..30d1deed 100644 --- a/src/statistics/distribution.rs +++ b/src/statistics/distribution.rs @@ -58,7 +58,7 @@ where { getter_copy!( /// Returns the parameter `a`. - pub, + pub const, param_exp, T ); @@ -181,7 +181,7 @@ where { getter_copy!( /// Returns the parameter `param_exp`. - pub, + pub const, param_exp, T ); @@ -302,7 +302,7 @@ where { getter_copy!( /// return the parameter `param_exp`. - pub, + pub const, param_exp, T ); From 697f1a721c3c27d775a9059f76958b64140d561f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=C3=A9nore=20Bouttefeux?= Date: Sun, 19 Jun 2022 11:00:04 +0200 Subject: [PATCH 2/2] update dependencies --- CHANGELOG.md | 8 ++++++++ Cargo.toml | 11 ++++++----- README.md | 2 +- procedural_macro/CHANGELOG.md | 10 ++++++++++ procedural_macro/Cargo.toml | 8 ++++---- procedural_macro/README.md | 2 +- procedural_macro/src/lib.rs | 2 +- src/lib.rs | 2 +- 8 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 procedural_macro/CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md index dc4214f9..e80b39bd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ +# v0.2.1 + +- add const on multiple functions where applicable +- update nalgebra to 0.31.0 +- update num-traits to 0.2.15 +- update rayon to 1.5.3 + + # v0.2.0 First release diff --git a/Cargo.toml b/Cargo.toml index 33a958c7..2d6b898f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lattice-qcd-rs" -version = "0.2.0" +version = "0.2.1" authors = ["AliƩnore Bouttefeux "] edition = "2021" readme = "README.md" @@ -10,6 +10,7 @@ description = "Lattice QCD simulation" keywords = ["QCD", "Lattice", "Monte-Carlo", "chromodynamics"] publish = true license = "MIT OR Apache-2.0" +rust-version = "1.61" [lib] path = "src/lib.rs" @@ -24,15 +25,15 @@ default = ["serde-serialize"] members = ["procedural_macro"] [dependencies] -nalgebra = { version = "0.31", features = ["serde-serialize"] } +nalgebra = { version = "0.31.0", features = ["serde-serialize"] } approx = "0.5.1" -num-traits = "0.2.14" +num-traits = "0.2.15" rand = "0.8.5" rand_distr = "0.4.3" crossbeam = "0.8.1" -rayon = "1.5.1" +rayon = "1.5.3" serde = { version = "1.0", features = ["derive"], optional = true } -lattice_qcd_rs-procedural_macro = {path = "procedural_macro", version = "0.2.0"} +lattice_qcd_rs-procedural_macro = {path = "procedural_macro", version = "0.2.1"} [dev-dependencies] criterion = "0.3.5" diff --git a/README.md b/README.md index 9cc24a69..32590ddd 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ Check out my other repo [plaquette](https://github.com/ABouttefeux/plaquette), a ## Usage -Add `lattice_qcd_rs = { version = "0.2.0", git = "https://github.com/ABouttefeux/lattice_qcd_rs" }` into your `cargo.toml`. +Add `lattice_qcd_rs = { version = "0.2.1", git = "https://github.com/ABouttefeux/lattice_qcd_rs" }` into your `cargo.toml`. The set of features are - `serde-serialize` on by default permit the use of serde on some structure - `no-overflow-test` usage interns to desable overflow test for coverage. diff --git a/procedural_macro/CHANGELOG.md b/procedural_macro/CHANGELOG.md new file mode 100644 index 00000000..9ffdb584 --- /dev/null +++ b/procedural_macro/CHANGELOG.md @@ -0,0 +1,10 @@ + +# v0.2.1 + +- update quote to 1.0.19 +- update syn to 1.0.98 +- update proc-macro2 to 1.0.39 + +# v0.2.0 + +First release diff --git a/procedural_macro/Cargo.toml b/procedural_macro/Cargo.toml index 8c4925da..ccbe949d 100644 --- a/procedural_macro/Cargo.toml +++ b/procedural_macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "lattice_qcd_rs-procedural_macro" -version = "0.2.0" +version = "0.2.1" authors = ["AliƩnore Bouttefeux "] edition = "2021" description = "Set of procedural macro for the main library lattice_qcd_rs" @@ -12,9 +12,9 @@ publish = true proc-macro = true [dependencies] -quote = "1.0.17" -syn = "1.0.90" -proc-macro2 = "1.0.36" +quote = "1.0.19" +syn = "1.0.98" +proc-macro2 = "1.0.39" [dev-dependencies] version-sync = "0.9.4" \ No newline at end of file diff --git a/procedural_macro/README.md b/procedural_macro/README.md index c5c3e352..026fa463 100644 --- a/procedural_macro/README.md +++ b/procedural_macro/README.md @@ -1,4 +1,4 @@ -# Procedural macro for lattice_qcd_rs v0.2.0 +# Procedural macro for lattice_qcd_rs v0.2.1 ![](https://img.shields.io/badge/language-Rust-orange) ![License](https://img.shields.io/badge/license-MIT_OR_Apache--2.0-blue.svg) diff --git a/procedural_macro/src/lib.rs b/procedural_macro/src/lib.rs index bb823373..fe761195 100644 --- a/procedural_macro/src/lib.rs +++ b/procedural_macro/src/lib.rs @@ -29,7 +29,7 @@ #![warn(clippy::missing_errors_doc)] #![warn(missing_docs)] #![forbid(unsafe_code)] -#![doc(html_root_url = "https://docs.rs/lattice_qcd_rs-procedural_macro/0.2.0")] +#![doc(html_root_url = "https://docs.rs/lattice_qcd_rs-procedural_macro/0.2.1")] /// Only contains the version test. #[cfg(test)] diff --git a/src/lib.rs b/src/lib.rs index c4caa606..8ef3f94e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,7 +29,7 @@ #![warn(clippy::missing_errors_doc)] #![warn(missing_docs)] #![forbid(unsafe_code)] -#![doc(html_root_url = "https://docs.rs/lattice_qcd_rs/0.2.0")] +#![doc(html_root_url = "https://docs.rs/lattice_qcd_rs/0.2.1")] extern crate approx; extern crate crossbeam;