# mod.rs - source
Source of the Rust file `maplibre/src/tcs/mod.rs`.

    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
    30

    use std::{any::TypeId, collections::HashSet};

    pub mod resources;
    pub mod system;
    pub mod tiles;
    pub mod world;

    #[derive(Default)]
    pub struct GlobalQueryState {
        mutably_borrowed: HashSet<TypeId>,
    }

    pub trait QueryState<'s> {
        fn create(state: &'s mut GlobalQueryState) -> Self;
        fn clone_to<'a, S: QueryState<'a>>(&'a mut self) -> S;
    }

    pub struct EphemeralQueryState<'s> {
        state: &'s mut GlobalQueryState,
    }

    impl<'s> QueryState<'s> for EphemeralQueryState<'s> {
        fn create(state: &'s mut GlobalQueryState) -> Self {
            Self { state }
        }

        fn clone_to<'a, S: QueryState<'a>>(&'a mut self) -> S {
            S::create(self.state)
        }
    }