# mod.rs - source
Source of the Rust file `maplibre/src/render/render_phase/mod.rs`.
Keywords: rust, rustlang, rust-lang

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29

    //! Describes the concept of a [`RenderPhase`] and [`PhaseItem`]

    mod draw;

    pub use draw::*;

    /// A resource to collect and sort draw requests for specific [`PhaseItems`](PhaseItem).
    pub struct RenderPhase<I: PhaseItem> {
        pub items: Vec<I>,
    }

    impl<I: PhaseItem> Default for RenderPhase<I> {
        fn default() -> Self {
            Self { items: Vec::new() }
        }
    }

    impl<I: PhaseItem> RenderPhase<I> {
        /// Adds a [`PhaseItem`] to this render phase.
        #[inline]
        pub fn add(&mut self, item: I) {
            self.items.push(item);
        }

        /// Sorts all of its [`PhaseItems`](PhaseItem).
        pub fn sort(&mut self) {
            self.items.sort_by_key(|d| d.sort_key());
        }
    }