Skip to content

Commit 1dd26e9

Browse files
eranfuLuthaf
eranfu
authored andcommitted
Make 'apply_permutation' function public
1 parent 7182fd3 commit 1dd26e9

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

soa-derive-internal/src/slice.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ pub fn derive_mut(input: &Input) -> TokenStream {
341341
nested_ord.push(quote! { for<'b> #ref_name<'b>: Ord });
342342

343343
let apply_permutation = input.map_fields_nested_or(
344-
|ident, _| quote! { self.#ident.apply_permutation(permutation) },
344+
|ident, _| quote! { self.#ident.__private_apply_permutation(permutation) },
345345
|ident, _| quote! { permutation.apply_slice_in_place(&mut self.#ident) },
346346
).collect::<Vec<_>>();
347347

@@ -616,7 +616,9 @@ pub fn derive_mut(input: &Input) -> TokenStream {
616616
}
617617

618618
#[doc(hidden)]
619-
fn apply_permutation(&mut self, permutation: &mut soa_derive::Permutation) {
619+
/// This is `pub` due to there will be compile-error if `#[nested_soa]` is used.
620+
/// Do not use this method directly.
621+
pub fn __private_apply_permutation(&mut self, permutation: &mut soa_derive::Permutation) {
620622
#( #apply_permutation; )*
621623
}
622624

@@ -633,7 +635,7 @@ pub fn derive_mut(input: &Input) -> TokenStream {
633635
permutation.sort_by(|j, k| f(self.index(*j), self.index(*k)));
634636

635637
let mut permutation = Permutation::oneline(permutation).inverse();
636-
self.apply_permutation(&mut permutation);
638+
self.__private_apply_permutation(&mut permutation);
637639
}
638640

639641
/// Similar to [`&mut
@@ -650,7 +652,7 @@ pub fn derive_mut(input: &Input) -> TokenStream {
650652
permutation.sort_by_key(|i| f(self.index(*i)));
651653

652654
let mut permutation = Permutation::oneline(permutation).inverse();
653-
self.apply_permutation(&mut permutation);
655+
self.__private_apply_permutation(&mut permutation);
654656
}
655657
}
656658

@@ -669,7 +671,7 @@ pub fn derive_mut(input: &Input) -> TokenStream {
669671
permutation.sort_by_key(|i| self.index(*i));
670672

671673
let mut permutation = Permutation::oneline(permutation).inverse();
672-
self.apply_permutation(&mut permutation);
674+
self.__private_apply_permutation(&mut permutation);
673675
}
674676
}
675677
};

tests/nested_soa.rs

+13-7
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,21 @@ pub struct Point {
66
y: f32,
77
}
88

9-
#[derive(Debug, Clone, PartialEq, StructOfArray)]
10-
#[soa_derive(Debug, Clone, PartialEq)]
11-
pub struct Color {
12-
pub r: u8,
13-
pub g: u8,
14-
pub b: u8,
15-
pub a: u8,
9+
mod other_mod {
10+
use soa_derive::StructOfArray;
11+
12+
#[derive(Debug, Clone, PartialEq, StructOfArray)]
13+
#[soa_derive(Debug, Clone, PartialEq)]
14+
pub struct Color {
15+
pub r: u8,
16+
pub g: u8,
17+
pub b: u8,
18+
pub a: u8,
19+
}
1620
}
1721

22+
use other_mod::*;
23+
1824
#[derive(Debug, Clone, PartialEq, StructOfArray)]
1925
#[soa_derive(Debug, Clone, PartialEq)]
2026
pub struct Particle {

0 commit comments

Comments
 (0)