Repository: bevyengine/bevy
File: crates/bevy_mesh/src/primitives/extrusion.rs (Rust)

Code before:
    /// A layer is the set of vertices sharing a common Z value or depth.
    fn vertices_per_layer(&self) -> u32 {
        match self {
            PerimeterSegment::Smooth { indices, .. } => indices.len() as u32,
            PerimeterSegment::Flat { indices } => 2 * (indices.len() as u32 - 1),
        }
    }

    /// Returns the amount of indices each 'segment' of the extrusion should include for this perimeter segment.
    ///
    /// A segment is the set of faces on the mantel of the extrusion between two layers of vertices.
    fn indices_per_segment(&self) -> usize {
        match self {
            PerimeterSegment::Smooth { indices, .. } | PerimeterSegment::Flat { indices } => {
                6 * (indices.len() - 1)
            }
        }
    }
}

/// A trait required for implementing `Meshable` for `Extrusion<T>`.
///
/// ## Warning
///
/// By implementing this trait you guarantee that the `primitive_topology` of the mesh returned by
/// this builder is [`PrimitiveTopology::TriangleList`](crate::PrimitiveTopology::TriangleList)
/// and that your mesh has a [`Mesh::ATTRIBUTE_POSITION`] attribute.
pub trait Extrudable: MeshBuilder {
    /// A list of the indices each representing a part of the perimeter of the mesh.
    fn perimeter(&self) -> Vec<PerimeterSegment>;
}

impl<P> Meshable for Extrusion<P>
where
    P: Primitive2d + Meshable,
    P::Output: Extrudable,
{
    type Output = ExtrusionBuilder<P>;

    fn mesh(&self) -> Self::Output {
        ExtrusionBuilder {
            base_builder: self.base_shape.mesh(),
            half_depth: self.half_depth,
            segments: 1,
        }
    }
}

/// A builder used for creating a [`Mesh`] with an [`Extrusion`] shape.
pub struct ExtrusionBuilder<P>
where

Review comment (suggestion):
```suggestion
/// this builder is [`PrimitiveTopology::TriangleList`](PrimitiveTopology::TriangleList)
```

(Nit) The `crate` shouldn't be necessary, since you import `PrimitiveTopology` already.

Code after:
    /// A layer is the set of vertices sharing a common Z value or depth.
    fn vertices_per_layer(&self) -> u32 {
        match self {
            PerimeterSegment::Smooth { indices, .. } => indices.len() as u32,
            PerimeterSegment::Flat { indices } => 2 * (indices.len() as u32 - 1),
        }
    }

    /// Returns the amount of indices each 'segment' of the extrusion should include for this perimeter segment.
    ///
    /// A segment is the set of faces on the mantel of the extrusion between two layers of vertices.
    fn indices_per_segment(&self) -> usize {
        match self {
            PerimeterSegment::Smooth { indices, .. } | PerimeterSegment::Flat { indices } => {
                6 * (indices.len() - 1)
            }
        }
    }
}

/// A trait required for implementing `Meshable` for `Extrusion<T>`.
///
/// ## Warning
///
/// By implementing this trait you guarantee that the `primitive_topology` of the mesh returned by
/// this builder is [`PrimitiveTopology::TriangleList`]
/// and that your mesh has a [`Mesh::ATTRIBUTE_POSITION`] attribute.
pub trait Extrudable: MeshBuilder {
    /// A list of the indices each representing a part of the perimeter of the mesh.
    fn perimeter(&self) -> Vec<PerimeterSegment>;
}

impl<P> Meshable for Extrusion<P>
where
    P: Primitive2d + Meshable,
    P::Output: Extrudable,
{
    type Output = ExtrusionBuilder<P>;

    fn mesh(&self) -> Self::Output {
        ExtrusionBuilder {
            base_builder: self.base_shape.mesh(),
            half_depth: self.half_depth,
            segments: 1,
        }
    }
}

/// A builder used for creating a [`Mesh`] with an [`Extrusion`] shape.
pub struct ExtrusionBuilder<P>
where