Skip to content

Commit

Permalink
Update order of code
Browse files Browse the repository at this point in the history
`Face` is more widely used than `Faces`, so it makes sense to put it
first.
  • Loading branch information
hannobraun committed Sep 21, 2022
1 parent 8ea30ea commit 2dab910
Showing 1 changed file with 48 additions and 48 deletions.
96 changes: 48 additions & 48 deletions crates/fj-kernel/src/objects/face.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,54 +7,6 @@ use crate::{builder::FaceBuilder, stores::Stores};

use super::{Cycle, Surface};

/// A collection of faces
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Faces {
inner: BTreeSet<Face>,
}

impl Faces {
/// Create an empty instance of `Faces`
pub fn new() -> Self {
Self::default()
}

/// Find the given face
pub fn find(&self, face: &Face) -> Option<Face> {
for f in self {
if f == face {
return Some(f.clone());
}
}

None
}
}

impl Extend<Face> for Faces {
fn extend<T: IntoIterator<Item = Face>>(&mut self, iter: T) {
self.inner.extend(iter)
}
}

impl IntoIterator for Faces {
type Item = Face;
type IntoIter = btree_set::IntoIter<Face>;

fn into_iter(self) -> Self::IntoIter {
self.inner.into_iter()
}
}

impl<'a> IntoIterator for &'a Faces {
type Item = &'a Face;
type IntoIter = btree_set::Iter<'a, Face>;

fn into_iter(self) -> Self::IntoIter {
self.inner.iter()
}
}

/// A face of a shape
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Face {
Expand Down Expand Up @@ -165,6 +117,54 @@ impl Face {
}
}

/// A collection of faces
#[derive(Clone, Debug, Default, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Faces {
inner: BTreeSet<Face>,
}

impl Faces {
/// Create an empty instance of `Faces`
pub fn new() -> Self {
Self::default()
}

/// Find the given face
pub fn find(&self, face: &Face) -> Option<Face> {
for f in self {
if f == face {
return Some(f.clone());
}
}

None
}
}

impl Extend<Face> for Faces {
fn extend<T: IntoIterator<Item = Face>>(&mut self, iter: T) {
self.inner.extend(iter)
}
}

impl IntoIterator for Faces {
type Item = Face;
type IntoIter = btree_set::IntoIter<Face>;

fn into_iter(self) -> Self::IntoIter {
self.inner.into_iter()
}
}

impl<'a> IntoIterator for &'a Faces {
type Item = &'a Face;
type IntoIter = btree_set::Iter<'a, Face>;

fn into_iter(self) -> Self::IntoIter {
self.inner.iter()
}
}

/// The handedness of a face's coordinate system
///
/// See [`Face::coord_handedness`].
Expand Down

0 comments on commit 2dab910

Please sign in to comment.