Skip to main content

Crate use_python_keyword

Crate use_python_keyword 

Source
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§

PythonKeyword
Common hard Python keywords.
PythonKeywordParseError
Error returned when a Python keyword label is empty or unknown.
PythonReservedWord
A hard or soft reserved Python word.
PythonSoftKeyword
Python soft keywords used by pattern matching and newer syntax contexts.

Functions§

is_python_keyword
Returns whether input is a hard Python keyword.
is_python_reserved_word
Returns whether input is either a hard or soft Python reserved word.
is_python_soft_keyword
Returns whether input is a Python soft keyword.