Skip to main content

has_attribute

Function has_attribute 

Source
pub fn has_attribute(name: &str) -> bool
Expand description

Whether __has_attribute(name) answers yes.

weak answers no although a declaration carrying it is accepted: what the question is really asked for is whether a weak reference can be tested for null, and here it cannot — the symbol has to be there at link time. A program that guards on the answer therefore takes the portable branch, and one that writes the attribute unguarded on a declaration — as glibc’s <pthread.h> does — is not stopped by it.