get_allocator_type

Function get_allocator_type 

Source
pub fn get_allocator_type() -> AllocatorType
Expand description

Get current allocator type

Returns the currently used allocator type, this is a simplified version of get_allocator_info(). If you only need to know the allocator type without other information, using this function is more concise.

§Return Value

Returns AllocatorType enum value, possible values:

§Example

use auto_allocator;

let allocator_type = auto_allocator::get_allocator_type();

// Simple allocator type check
if allocator_type == auto_allocator::AllocatorType::Mimalloc {
    println!("Using high-performance mimalloc allocator");
}

// Or use match statement
match allocator_type {
    auto_allocator::AllocatorType::Mimalloc => {
        println!("mimalloc - optimal performance");
    }
    auto_allocator::AllocatorType::System => {
        println!("system - maximum compatibility");
    }
    _ => println!("other allocator"),
}

§Performance Notes

This function is slightly faster than get_allocator_info() because it only returns type information.