pub struct Identifier { /* private fields */ }
Expand description
A simple identifier (not an expression, not a variable with sections)
Used for names that appear in various contexts:
- Variable names:
x
,my_var
- Function names:
my_function
- Allocator names:
omp_default_mem_alloc
- Mapper names:
my_mapper
- User-defined reduction operators:
my_reduction_op
§Learning: Newtype Pattern
This is a “newtype” - a struct with a single field that wraps another type.
Why not just use &str
directly?
- Type safety: Can’t accidentally pass an expression where identifier expected
- Semantic clarity: Code documents intent
- Future extension: Can add validation, normalization, etc.
- Zero cost: Compiler optimizes away the wrapper
§Example
use roup::ir::Identifier;
let id = Identifier::new("my_var");
assert_eq!(id.name(), "my_var");
assert_eq!(format!("{}", id), "my_var");
Implementations§
Trait Implementations§
Source§impl Clone for Identifier
impl Clone for Identifier
Source§fn clone(&self) -> Identifier
fn clone(&self) -> Identifier
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for Identifier
impl Debug for Identifier
Source§impl Display for Identifier
impl Display for Identifier
Source§impl From<&str> for Identifier
impl From<&str> for Identifier
Source§impl From<Identifier> for ClauseItem
impl From<Identifier> for ClauseItem
Source§fn from(id: Identifier) -> Self
fn from(id: Identifier) -> Self
Converts to this type from the input type.
Source§impl From<Identifier> for Variable
impl From<Identifier> for Variable
Source§fn from(id: Identifier) -> Self
fn from(id: Identifier) -> Self
Converts to this type from the input type.
Source§impl From<String> for Identifier
impl From<String> for Identifier
Source§impl Hash for Identifier
impl Hash for Identifier
Source§impl PartialEq for Identifier
impl PartialEq for Identifier
impl Eq for Identifier
impl StructuralPartialEq for Identifier
Auto Trait Implementations§
impl Freeze for Identifier
impl RefUnwindSafe for Identifier
impl Send for Identifier
impl Sync for Identifier
impl Unpin for Identifier
impl UnwindSafe for Identifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more