cairo_lang_semantic/expr/
fmt.rs

1use cairo_lang_defs::db::DefsGroup;
2use cairo_lang_defs::ids::FunctionWithBodyId;
3use cairo_lang_utils::Upcast;
4
5use crate::db::SemanticGroup;
6
7/// Holds all the information needed for formatting expressions.
8/// Acts like a "db" for DebugWithDb.
9pub struct ExprFormatter<'a> {
10    pub db: &'a (dyn SemanticGroup + 'static),
11    pub function_id: FunctionWithBodyId,
12}
13
14impl Upcast<dyn SemanticGroup + 'static> for ExprFormatter<'_> {
15    fn upcast(&self) -> &(dyn SemanticGroup + 'static) {
16        self.db
17    }
18}
19impl Upcast<dyn DefsGroup + 'static> for ExprFormatter<'_> {
20    fn upcast(&self) -> &(dyn DefsGroup + 'static) {
21        self.db.upcast()
22    }
23}