pub struct Attribute { /* private fields */ }
Expand description

Functions, function parameters, and return types can have Attributes to indicate how they should be treated by optimizations and code generation.

Implementations

Determines whether or not an Attribute is an enum. This method will likely be removed in the future in favor of Attributes being generically defined.

Example
use inkwell::context::Context;

let context = Context::create();
let enum_attribute = context.create_enum_attribute(0, 10);

assert!(enum_attribute.is_enum());

Determines whether or not an Attribute is a string. This method will likely be removed in the future in favor of Attributes being generically defined.

Example
use inkwell::context::Context;

let context = Context::create();
let string_attribute = context.create_string_attribute("my_key_123", "my_val");

assert!(string_attribute.is_string());

Gets the enum kind id associated with a builtin name.

Example
use inkwell::attributes::Attribute;

// This kind id doesn't exist:
assert_eq!(Attribute::get_named_enum_kind_id("foobar"), 0);

// These are real kind ids:
assert_eq!(Attribute::get_named_enum_kind_id("align"), 1);
assert_eq!(Attribute::get_named_enum_kind_id("builtin"), 5);

Gets the kind id associated with an enum Attribute.

Example
use inkwell::context::Context;

let context = Context::create();
let enum_attribute = context.create_enum_attribute(0, 10);

assert_eq!(enum_attribute.get_enum_kind_id(), 0);

Gets the last enum kind id associated with builtin names.

Example
use inkwell::attributes::Attribute;

assert_eq!(Attribute::get_last_enum_kind_id(), 56);

Gets the value associated with an enum Attribute.

Example
use inkwell::context::Context;

let context = Context::create();
let enum_attribute = context.create_enum_attribute(0, 10);

assert_eq!(enum_attribute.get_enum_value(), 10);

Gets the string kind id associated with a string attribute.

Example
use inkwell::context::Context;

let context = Context::create();
let string_attribute = context.create_string_attribute("my_key", "my_val");

assert_eq!(string_attribute.get_string_kind_id().to_str(), Ok("my_key"));

Gets the string value associated with a string attribute.

Example
use inkwell::context::Context;

let context = Context::create();
let string_attribute = context.create_string_attribute("my_key", "my_val");

assert_eq!(string_attribute.get_string_value().to_str(), Ok("my_val"));

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.