-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vector's iter method is private for non public structs #69
Comments
Ok. found a cause. The struct should be public to make iter accessible. |
So we have the Could we have |
Is the issue coming from the fact that the function is private or that the returned types are private? We could make the types public anyway, I think I remember that creating "detail" modules like this was a bit problematic for the compiler. |
All methods defined for #[allow(non_snake_case, dead_code)]
mod __detail_iter_megastruct {
...
impl MegaStructVec {
/// Get a mutable iterator over the
///[`MegaStructRefMut`](struct.MegaStructRefMut.html)
/// in this vector
fn iter_mut(&mut self) -> IterMut {
self.as_mut_slice().into_iter()
}
}
impl<'a> MegaStructSliceMut<'a> {
/// Get an iterator over the
///[`MegaStructRef`](struct.MegaStructRef.html)
/// in this vector
fn iter(&mut self) -> Iter {
self.as_ref().into_iter()
}
/// Get a mutable iterator over the
///[`MegaStructRefMut`](struct.MegaStructRefMut.html)
/// in this vector
fn iter_mut(&mut self) -> IterMut {
IterMut(self.foo.iter_mut().zip(self.bar.iter_mut()))
}
/// Get a mutable iterator over the
///[`MegaStructRefMut`](struct.MegaStructRefMut.html)
/// in this vector
fn into_iter(self) -> IterMut<'a> {
IterMut(self.foo.iter_mut().zip(self.bar.iter_mut()))
}
}
...
} |
If we define the original structure as pub(super) struct MegaStruct {
foo: usize,
bar: usize,
}
…
#[allow(dead_code)]
pub(super) struct MegaStructVec {
…
}
…
#[allow(non_snake_case, dead_code)]
mod __detail_iter_megastruct {
use super::*;
use std::slice;
#[allow(unused_imports)]
use std::iter;
#[allow(missing_debug_implementations)]
pub(super) struct Iter<'a>(
pub(super) iter::Zip<slice::Iter<'a, usize>, slice::Iter<'a, usize>>,
);
…
impl MegaStructVec {
/// Get an iterator over the
///[`MegaStructRef`](struct.MegaStructRef.html)
/// in this vector
pub(super) fn iter(&self) -> Iter {
self.as_slice().into_iter()
}
}
impl<'a> MegaStructSlice<'a> {
/// Get an iterator over the
///[`MegaStructRef`](struct.MegaStructRef.html)
/// in this slice.
pub(super) fn iter(&self) -> Iter {
Iter(self.foo.iter().zip(self.bar.iter()))
}
/// Get an iterator over the
///[`MegaStructRef`](struct.MegaStructRef.html)
/// in this slice.
pub(super) fn into_iter(self) -> Iter<'a> {
Iter(self.foo.iter().zip(self.bar.iter()))
}
}
#[allow(missing_debug_implementations)]
pub(super) struct IterMut<'a>(
pub(super) iter::Zip<slice::IterMut<'a, usize>, slice::IterMut<'a, usize>>,
);
…
impl MegaStructVec {
/// Get a mutable iterator over the
///[`MegaStructRefMut`](struct.MegaStructRefMut.html)
/// in this vector
pub(super) fn iter_mut(&mut self) -> IterMut {
self.as_mut_slice().into_iter()
}
}
impl<'a> MegaStructSliceMut<'a> {
/// Get an iterator over the
///[`MegaStructRef`](struct.MegaStructRef.html)
/// in this vector
pub(super) fn iter(&mut self) -> Iter {
self.as_ref().into_iter()
}
/// Get a mutable iterator over the
///[`MegaStructRefMut`](struct.MegaStructRefMut.html)
/// in this vector
pub(super) fn iter_mut(&mut self) -> IterMut {
IterMut(self.foo.iter_mut().zip(self.bar.iter_mut()))
}
/// Get a mutable iterator over the
///[`MegaStructRefMut`](struct.MegaStructRefMut.html)
/// in this vector
pub(super) fn into_iter(self) -> IterMut<'a> {
IterMut(self.foo.iter_mut().zip(self.bar.iter_mut()))
}
}
impl<'a> soa_derive::SoAIter<'a> for MegaStruct {
type Iter = Iter<'a>;
type IterMut = IterMut<'a>;
}
} |
I have an error:
In this code:
What I am doing wrong?
The text was updated successfully, but these errors were encountered: