Skip to main content

TypeImplsInterface

Trait TypeImplsInterface 

Source
pub trait TypeImplsInterface<I: ?Sized + TypeInterfaceMarker + 'static>: Type { }
Expand description

A static promise that the Type Self implements the type interface I.

This is auto implemented by type_interface_impl for every Type that implements an interface. A manual implementation making a false promise will trigger a runtime panic.

See also type_impls_static, which answers the same question at run time.

Example:

ⓘ
use pliron::{
    builtin::{type_interfaces::FloatTypeInterface, types::IntegerType},
    context::Context,
    r#type::TypeInterfaceHandle,
};

let ctx = &mut Context::new();
let i32_ty = IntegerType::get(ctx, 32, pliron::builtin::types::Signedness::Signed);
// Compilation fails: `IntegerType` does not implement `FloatTypeInterface`.
let handle: TypeInterfaceHandle<dyn FloatTypeInterface> = i32_ty.into();

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§