Expand description
§use-python-identifier
ASCII-safe Python identifier primitives for RustUse.
§Experimental
use-python-identifier is experimental while use-python remains below 0.3.0.
§Example
use use_python_identifier::{PythonIdentifier, is_valid_ascii_python_identifier};
let identifier = PythonIdentifier::new("async_task")?;
assert_eq!(identifier.as_str(), "async_task");
assert!(is_valid_ascii_python_identifier("_value_1"));§Scope
- Ordinary ASCII-safe Python identifier validation.
- Hard Python keyword rejection through
use-python-keyword. - Dunder-name and private-name metadata helpers.
§Non-goals
- Complete Unicode Python identifier validation.
- Soft-keyword context analysis.
- Python source-code parsing.
Unicode-complete Python identifier validation is future work.
§License
Licensed under either Apache-2.0 or MIT.
Structs§
- Python
Dunder Name - Validated Python dunder name metadata.
- Python
Identifier - Validated ASCII-safe Python identifier.
- Python
Private Name - Validated Python private-name metadata.
Enums§
- Python
Identifier Error - Error returned when an ASCII Python identifier is invalid.
Functions§
- is_
ascii_ python_ identifier_ continue - Returns whether
characteris accepted after the first identifier character. - is_
ascii_ python_ identifier_ start - Returns whether
characteris accepted as an ASCII Python identifier start. - is_
dunder_ name - Returns whether
inputlooks like a Python dunder name such as__init__. - is_
private_ name - Returns whether
inputlooks like a single-underscore private name. - is_
valid_ ascii_ python_ identifier - Returns whether
inputis an ASCII-safe Python identifier and not a hard keyword.