Expand description
§use-python-keyword
Python keyword and soft-keyword primitives for RustUse.
§Experimental
use-python-keyword is experimental while use-python remains below 0.3.0.
§Example
use use_python_keyword::{PythonKeyword, is_python_reserved_word};
let keyword: PythonKeyword = "async".parse()?;
assert_eq!(keyword.to_string(), "async");
assert!(is_python_reserved_word("match"));§Scope
- Common hard Python keywords.
- Common soft keywords such as
match,case,type, and_. - Display and parse helpers that preserve Python source spelling.
§Non-goals
- Parsing Python source code.
- Determining whether a soft keyword is active in a specific grammar context.
- Tracking future Python grammar changes at runtime.
§License
Licensed under either Apache-2.0 or MIT.
Enums§
- Python
Keyword - Common hard Python keywords.
- Python
Keyword Parse Error - Error returned when a Python keyword label is empty or unknown.
- Python
Reserved Word - A hard or soft reserved Python word.
- Python
Soft Keyword - Python soft keywords used by pattern matching and newer syntax contexts.
Functions§
- is_
python_ keyword - Returns whether
inputis a hard Python keyword. - is_
python_ reserved_ word - Returns whether
inputis either a hard or soft Python reserved word. - is_
python_ soft_ keyword - Returns whether
inputis a Python soft keyword.