pub trait Attribute:
Printable
+ Verify
+ Downcast
+ Sync
+ Send
+ DynClone
+ Debug {
// Required methods
fn hash_attr(&self) -> TypeValueHash;
fn eq_attr(&self, other: &(dyn Attribute + 'static)) -> bool;
fn get_attr_id(&self) -> AttrId;
fn get_attr_id_static() -> AttrId
where Self: Sized;
// Provided method
fn register<A>(ctx: &mut Context)
where A: Attribute,
Self: Sized + Parsable<Arg = (), Parsed = A> { ... }
}Expand description
Basic functionality that every attribute in the IR must implement.
See module documentation for more information.
Required Methods§
Sourcefn hash_attr(&self) -> TypeValueHash
fn hash_attr(&self) -> TypeValueHash
Compute and get the hash for this instance of Self. Hash collisions can be a possibility.
Sourcefn eq_attr(&self, other: &(dyn Attribute + 'static)) -> bool
fn eq_attr(&self, other: &(dyn Attribute + 'static)) -> bool
Is self equal to an other Attribute?
Sourcefn get_attr_id(&self) -> AttrId
fn get_attr_id(&self) -> AttrId
Get an Attribute’s static name. This is not per instantnce. It is mostly useful for printing and parsing the attribute.
Sourcefn get_attr_id_static() -> AttrIdwhere
Self: Sized,
fn get_attr_id_static() -> AttrIdwhere
Self: Sized,
Same as get_attr_id, but without the self reference.
Provided Methods§
Implementations§
Source§impl dyn Attribute
impl dyn Attribute
Sourcepub fn is<__T>(&self) -> boolwhere
__T: Attribute,
pub fn is<__T>(&self) -> boolwhere
__T: Attribute,
Returns true if the trait object wraps an object of type __T.
Sourcepub fn downcast<__T>(
self: Box<dyn Attribute>,
) -> Result<Box<__T>, Box<dyn Attribute>>where
__T: Attribute,
pub fn downcast<__T>(
self: Box<dyn Attribute>,
) -> Result<Box<__T>, Box<dyn Attribute>>where
__T: Attribute,
Returns a boxed object from a boxed trait object if the underlying object is of type
__T. Returns the original boxed trait if it isn’t.
Sourcepub fn downcast_rc<__T>(
self: Rc<dyn Attribute>,
) -> Result<Rc<__T>, Rc<dyn Attribute>>where
__T: Attribute,
pub fn downcast_rc<__T>(
self: Rc<dyn Attribute>,
) -> Result<Rc<__T>, Rc<dyn Attribute>>where
__T: Attribute,
Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of
type __T. Returns the original Rc-ed trait if it isn’t.
Sourcepub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: Attribute,
pub fn downcast_ref<__T>(&self) -> Option<&__T>where
__T: Attribute,
Returns a reference to the object within the trait object if it is of type __T, or
None if it isn’t.
Sourcepub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: Attribute,
pub fn downcast_mut<__T>(&mut self) -> Option<&mut __T>where
__T: Attribute,
Returns a mutable reference to the object within the trait object if it is of type
__T, or None if it isn’t.
Trait Implementations§
Source§impl CloneIntoContext for Box<dyn Attribute>
impl CloneIntoContext for Box<dyn Attribute>
impl Eq for Box<dyn Attribute>
Source§impl Parsable for Box<dyn Attribute>
impl Parsable for Box<dyn Attribute>
Source§fn parse<'a>(
state_stream: &mut Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>,
_arg: <Box<dyn Attribute> as Parsable>::Arg,
) -> Result<(<Box<dyn Attribute> as Parsable>::Parsed, Commit<()>), Commit<Tracked<<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>> as StreamOnce>::Error>>>
fn parse<'a>( state_stream: &mut Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, _arg: <Box<dyn Attribute> as Parsable>::Arg, ) -> Result<(<Box<dyn Attribute> as Parsable>::Parsed, Commit<()>), Commit<Tracked<<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>> as StreamOnce>::Error>>>
into on Parser::parse_stream to get the final ParseResult.
Use state_stream.state as necessary.Source§fn parser<'a>(
arg: Self::Arg,
) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = Self::Parsed> + 'a>where
Self::Parsed: 'a,
fn parser<'a>(
arg: Self::Arg,
) -> Box<dyn Parser<Stream<Stream<Stream<Stream<IteratorStream<CharIterator<'a>>, SourcePosition>>>, State<'a>>, PartialState = (), Output = Self::Parsed> + 'a>where
Self::Parsed: 'a,
Source§impl Printable for Box<dyn Attribute>
impl Printable for Box<dyn Attribute>
Source§impl StableHash for Box<dyn Attribute>
impl StableHash for Box<dyn Attribute>
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".