Rust: impl IntoIterator
for FlavourColours
This moves the `into_iter` method into the `IntoIterator` trait implementation and switches to using values instead of references Closes #28
This commit is contained in:
parent
b27829caea
commit
1684c22392
1 changed files with 31 additions and 28 deletions
|
@ -31,36 +31,39 @@ pub struct FlavourColours {
|
|||
pub crust: Colour,
|
||||
}
|
||||
|
||||
impl FlavourColours {
|
||||
impl IntoIterator for FlavourColours {
|
||||
type Item = Colour;
|
||||
type IntoIter = std::array::IntoIter<Self::Item, 26>;
|
||||
|
||||
/// Returns an iterator over the colours in the flavour.
|
||||
pub fn into_iter(&self) -> std::array::IntoIter<&Colour, 26> {
|
||||
fn into_iter(self) -> std::array::IntoIter<Colour, 26> {
|
||||
[
|
||||
&self.rosewater,
|
||||
&self.flamingo,
|
||||
&self.pink,
|
||||
&self.mauve,
|
||||
&self.red,
|
||||
&self.maroon,
|
||||
&self.peach,
|
||||
&self.yellow,
|
||||
&self.green,
|
||||
&self.teal,
|
||||
&self.sky,
|
||||
&self.sapphire,
|
||||
&self.blue,
|
||||
&self.lavender,
|
||||
&self.text,
|
||||
&self.subtext1,
|
||||
&self.subtext0,
|
||||
&self.overlay2,
|
||||
&self.overlay1,
|
||||
&self.overlay0,
|
||||
&self.surface2,
|
||||
&self.surface1,
|
||||
&self.surface0,
|
||||
&self.base,
|
||||
&self.mantle,
|
||||
&self.crust,
|
||||
self.rosewater,
|
||||
self.flamingo,
|
||||
self.pink,
|
||||
self.mauve,
|
||||
self.red,
|
||||
self.maroon,
|
||||
self.peach,
|
||||
self.yellow,
|
||||
self.green,
|
||||
self.teal,
|
||||
self.sky,
|
||||
self.sapphire,
|
||||
self.blue,
|
||||
self.lavender,
|
||||
self.text,
|
||||
self.subtext1,
|
||||
self.subtext0,
|
||||
self.overlay2,
|
||||
self.overlay1,
|
||||
self.overlay0,
|
||||
self.surface2,
|
||||
self.surface1,
|
||||
self.surface0,
|
||||
self.base,
|
||||
self.mantle,
|
||||
self.crust,
|
||||
]
|
||||
.into_iter()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue