cairo_lang_sierra/extensions/modules/
uninitialized.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
31
32
33
use crate::extensions::SpecializationError;
use crate::extensions::type_specialization_context::TypeSpecializationContext;
use crate::extensions::types::{
    GenericTypeArgGenericType, GenericTypeArgGenericTypeWrapper, TypeInfo,
};
use crate::ids::GenericTypeId;

/// Uninitialized value of type T.
#[derive(Default)]
pub struct UninitializedTypeWrapped {}
impl GenericTypeArgGenericType for UninitializedTypeWrapped {
    const ID: GenericTypeId = GenericTypeId::new_inline("Uninitialized");

    fn calc_info(
        &self,
        _context: &dyn TypeSpecializationContext,
        long_id: crate::program::ConcreteTypeLongId,
        TypeInfo { storable, zero_sized, .. }: TypeInfo,
    ) -> Result<TypeInfo, SpecializationError> {
        if storable {
            Ok(TypeInfo {
                long_id,
                storable: false,
                droppable: true,
                duplicatable: false,
                zero_sized,
            })
        } else {
            Err(SpecializationError::UnsupportedGenericArg)
        }
    }
}
pub type UninitializedType = GenericTypeArgGenericTypeWrapper<UninitializedTypeWrapped>;