pub unsafe trait BasicType<'ctx>: AnyType<'ctx> {
    // Provided methods
    fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx> { ... }
    fn fn_type(
        &self,
        param_types: &[BasicMetadataTypeEnum<'ctx>],
        is_var_args: bool
    ) -> FunctionType<'ctx> { ... }
    fn is_sized(&self) -> bool { ... }
    fn size_of(&self) -> Option<IntValue<'ctx>> { ... }
    fn array_type(&self, size: u32) -> ArrayType<'ctx> { ... }
    fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx> { ... }
}Expand description
Represents a basic LLVM type, that may be used in functions and struct definitions.
Provided Methods§
sourcefn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>
 
fn as_basic_type_enum(&self) -> BasicTypeEnum<'ctx>
Returns a BasicTypeEnum that represents the current type.
sourcefn fn_type(
    &self,
    param_types: &[BasicMetadataTypeEnum<'ctx>],
    is_var_args: bool
) -> FunctionType<'ctx>
 
fn fn_type( &self, param_types: &[BasicMetadataTypeEnum<'ctx>], is_var_args: bool ) -> FunctionType<'ctx>
Create a FunctionType with this BasicType as its return type.
Example:
use inkwell::context::Context;
use inkwell::types::BasicType;
let context = Context::create();
let int = context.i32_type();
let int_basic_type = int.as_basic_type_enum();
assert_eq!(int_basic_type.fn_type(&[], false), int.fn_type(&[], false));sourcefn is_sized(&self) -> bool
 
fn is_sized(&self) -> bool
Determines whether or not this BasicType is sized or not.
For example, opaque structs are unsized.
Example
use inkwell::context::Context;
use inkwell::types::BasicType;
let context = Context::create();
let f32_type = context.f32_type();
let f32_vec_type = f32_type.vec_type(40);
assert!(f32_vec_type.is_sized());sourcefn size_of(&self) -> Option<IntValue<'ctx>>
 
fn size_of(&self) -> Option<IntValue<'ctx>>
Gets the size of this BasicType. Value may vary depending on the target architecture.
Example
use inkwell::context::Context;
use inkwell::types::BasicType;
let context = Context::create();
let f32_type = context.f32_type();
let f32_basic_type = f32_type.as_basic_type_enum();
let f32_type_size = f32_basic_type.size_of();sourcefn array_type(&self, size: u32) -> ArrayType<'ctx>
 
fn array_type(&self, size: u32) -> ArrayType<'ctx>
Create an ArrayType with this BasicType as its elements.
Example:
use inkwell::context::Context;
use inkwell::types::BasicType;
let context = Context::create();
let int = context.i32_type();
let int_basic_type = int.as_basic_type_enum();
assert_eq!(int_basic_type.array_type(32), int.array_type(32));sourcefn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>
 
fn ptr_type(&self, address_space: AddressSpace) -> PointerType<'ctx>
Create a PointerType that points to this BasicType.
Example:
use inkwell::context::Context;
use inkwell::types::BasicType;
use inkwell::AddressSpace;
let context = Context::create();
let int = context.i32_type();
let int_basic_type = int.as_basic_type_enum();
let addr_space = AddressSpace::default();
assert_eq!(int_basic_type.ptr_type(addr_space), int.ptr_type(addr_space));