cairo_lang_semantic/expr/
fmt.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use cairo_lang_defs::db::DefsGroup;
use cairo_lang_defs::ids::FunctionWithBodyId;
use cairo_lang_utils::Upcast;

use crate::db::SemanticGroup;

/// Holds all the information needed for formatting expressions.
/// Acts like a "db" for DebugWithDb.
pub struct ExprFormatter<'a> {
    pub db: &'a (dyn SemanticGroup + 'static),
    pub function_id: FunctionWithBodyId,
}

impl Upcast<dyn SemanticGroup + 'static> for ExprFormatter<'_> {
    fn upcast(&self) -> &(dyn SemanticGroup + 'static) {
        self.db
    }
}
impl Upcast<dyn DefsGroup + 'static> for ExprFormatter<'_> {
    fn upcast(&self) -> &(dyn DefsGroup + 'static) {
        self.db.upcast()
    }
}