Skip to content

Commit 648f2b0

Browse files
author
Guillaume Fraux
committed
Update soa-derive to use edition 2018
1 parent d50bec0 commit 648f2b0

File tree

10 files changed

+22
-40
lines changed

10 files changed

+22
-40
lines changed

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[package]
22
name = "soa_derive"
3-
version = "0.7.0"
3+
version = "0.8.0"
4+
edition = "2018"
45
authors = ["Guillaume Fraux <guillaume.fraux@chimie-paristech.fr>"]
56
license = "MIT/Apache-2.0"
67
readme = "README.md"
@@ -18,7 +19,7 @@ members = [
1819
]
1920

2021
[dependencies]
21-
soa_derive_internal = {path = "soa-derive-internal", version = "0.6"}
22+
soa_derive_internal = {path = "soa-derive-internal", version = "0.8"}
2223

2324
[dev-dependencies]
2425
bencher = "0.1"

src/lib.rs

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,7 @@
158158
// The proc macro is implemented in soa_derive_internal, and re-exported by this
159159
// crate. This is because a single crate can not define both a proc macro and a
160160
// macro_rules macro.
161-
#[allow(unused_imports)]
162-
#[macro_use]
163-
extern crate soa_derive_internal;
164-
#[doc(hidden)]
165-
pub use soa_derive_internal::*;
161+
pub use soa_derive_internal::StructOfArray;
166162

167163
/// Create an iterator over multiple fields in a Struct of array style vector.
168164
///
@@ -225,7 +221,7 @@ pub use soa_derive_internal::*;
225221
macro_rules! soa_zip {
226222
($self: expr, [$($fields: tt)*] $(, $external: expr)* $(,)*) => {{
227223
let this = $self;
228-
soa_zip_impl!(@munch this, {$($fields)*} -> [] $($external ,)*)
224+
$crate::soa_zip_impl!(@munch this, {$($fields)*} -> [] $($external ,)*)
229225
}};
230226
}
231227

@@ -239,36 +235,36 @@ macro_rules! soa_zip_impl {
239235
};
240236
// Eat an element ($_iter) and add it to the current closure. Then recurse
241237
(@flatten $p:pat => ( $($tup:tt)* ) , $_iter:expr $( , $tail:expr )* ) => {
242-
soa_zip_impl!(@flatten ($p, a) => ( $($tup)*, a ) $( , $tail )*)
238+
$crate::soa_zip_impl!(@flatten ($p, a) => ( $($tup)*, a ) $( , $tail )*)
243239
};
244240

245241
// The main code is emmited here: we create an iterator, zip it and then
246242
// map the zipped iterator to flatten it
247-
(@final , $first: expr, $($tail: expr,)*) => {
243+
(@last , $first: expr, $($tail: expr,)*) => {
248244
::std::iter::IntoIterator::into_iter($first)
249245
$(
250246
.zip($tail)
251247
)*
252248
.map(
253-
soa_zip_impl!(@flatten a => (a) $( , $tail )*)
249+
$crate::soa_zip_impl!(@flatten a => (a) $( , $tail )*)
254250
)
255251
};
256252

257253
// Eat the last `mut $field` and then emit code
258254
(@munch $self: expr, {mut $field: ident} -> [$($output: tt)*] $($ext: expr ,)*) => {
259-
soa_zip_impl!(@final $($output)*, $self.$field.iter_mut(), $($ext, )*)
255+
$crate::soa_zip_impl!(@last $($output)*, $self.$field.iter_mut(), $($ext, )*)
260256
};
261257
// Eat the last `$field` and then emit code
262258
(@munch $self: expr, {$field: ident} -> [$($output: tt)*] $($ext: expr ,)*) => {
263-
soa_zip_impl!(@final $($output)*, $self.$field.iter(), $($ext, )*)
259+
$crate::soa_zip_impl!(@last $($output)*, $self.$field.iter(), $($ext, )*)
264260
};
265261

266262
// Eat the next `mut $field` and then recurse
267263
(@munch $self: expr, {mut $field: ident, $($tail: tt)*} -> [$($output: tt)*] $($ext: expr ,)*) => {
268-
soa_zip_impl!(@munch $self, {$($tail)*} -> [$($output)*, $self.$field.iter_mut()] $($ext, )*)
264+
$crate::soa_zip_impl!(@munch $self, {$($tail)*} -> [$($output)*, $self.$field.iter_mut()] $($ext, )*)
269265
};
270266
// Eat the next `$field` and then recurse
271267
(@munch $self: expr, {$field: ident, $($tail: tt)*} -> [$($output: tt)*] $($ext: expr ,)*) => {
272-
soa_zip_impl!(@munch $self, {$($tail)*} -> [$($output)*, $self.$field.iter()] $($ext, )*)
268+
$crate::soa_zip_impl!(@munch $self, {$($tail)*} -> [$($output)*, $self.$field.iter()] $($ext, )*)
273269
};
274270
}

tests/extreme.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![deny(warnings)]
22

3-
#[macro_use]
4-
extern crate soa_derive;
3+
use soa_derive::StructOfArray;
54

65
// This test checks that the derive code works even in some extreme cases
76

tests/iter.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#[macro_use]
2-
extern crate soa_derive;
31
mod particles;
42

5-
use particles::{Particle, ParticleVec};
3+
use self::particles::{Particle, ParticleVec};
64

75
#[test]
86
fn iter() {

tests/particles/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#![forbid(warnings)]
22

3+
use soa_derive::StructOfArray;
4+
35
#[derive(Debug, Clone, PartialEq, StructOfArray)]
46
#[soa_derive = "Debug, Clone, PartialEq"]
57
pub struct Particle {

tests/ptr.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#[macro_use]
2-
extern crate soa_derive;
31
mod particles;
4-
5-
use particles::{Particle, ParticleVec, ParticleSlice, ParticleSliceMut};
2+
use self::particles::{Particle, ParticleVec, ParticleSlice, ParticleSliceMut};
63

74
#[test]
85
fn const_ref() {

tests/slice.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#[macro_use]
2-
extern crate soa_derive;
31
mod particles;
4-
5-
use particles::{Particle, ParticleVec};
2+
use self::particles::{Particle, ParticleVec};
63

74
#[test]
85
fn len() {

tests/slice_mut.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#[macro_use]
2-
extern crate soa_derive;
31
mod particles;
4-
5-
use particles::{Particle, ParticleVec};
2+
use self::particles::{Particle, ParticleVec};
63

74
#[test]
85
fn len() {

tests/vec.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#[macro_use]
2-
extern crate soa_derive;
31
mod particles;
4-
5-
use particles::{Particle, ParticleVec};
2+
use self::particles::{Particle, ParticleVec};
63

74
#[test]
85
fn push() {

tests/zip.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
#[macro_use]
2-
extern crate soa_derive;
1+
use soa_derive::soa_zip;
32
mod particles;
4-
5-
use particles::{Particle, ParticleVec, ParticleSlice, ParticleSliceMut};
3+
use self::particles::{Particle, ParticleVec, ParticleSlice, ParticleSliceMut};
64

75
#[test]
86
fn vec() {

0 commit comments

Comments
 (0)