bevy_reflect/
type_info_stack.rsuse crate::TypeInfo;
use core::{
fmt::{Debug, Formatter},
slice::Iter,
};
#[derive(Default, Clone)]
pub(crate) struct TypeInfoStack {
stack: Vec<&'static TypeInfo>,
}
impl TypeInfoStack {
pub const fn new() -> Self {
Self { stack: Vec::new() }
}
pub fn push(&mut self, type_info: &'static TypeInfo) {
self.stack.push(type_info);
}
pub fn pop(&mut self) {
self.stack.pop();
}
pub fn iter(&self) -> Iter<&'static TypeInfo> {
self.stack.iter()
}
}
impl Debug for TypeInfoStack {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
let mut iter = self.iter();
if let Some(first) = iter.next() {
write!(f, "`{}`", first.type_path())?;
}
for info in iter {
write!(f, " -> `{}`", info.type_path())?;
}
Ok(())
}
}