Skip to main content

Crate use_go_identifier

Crate use_go_identifier 

Source
Expand description

§use-go-identifier

ASCII-safe Go identifier primitives for RustUse.

§Experimental

use-go-identifier is experimental while use-go remains below 0.3.0.

§Example

use use_go_identifier::{GoExportedIdentifier, GoIdentifier, is_valid_ascii_go_identifier};

let identifier = GoIdentifier::new("ServeHTTP")?;
let exported = GoExportedIdentifier::new("ServeHTTP")?;

assert_eq!(identifier.as_str(), "ServeHTTP");
assert_eq!(exported.as_str(), "ServeHTTP");
assert!(is_valid_ascii_go_identifier("handler_1"));

§Scope

  • Ordinary ASCII-safe Go identifier validation.
  • Exported identifiers that start with an uppercase ASCII letter.
  • Unexported identifiers that start with a lowercase ASCII letter or underscore.

§Non-goals

  • Complete Unicode Go identifier validation.
  • Keyword or predeclared identifier checks.
  • Go source-code parsing.

Unicode-complete Go identifier validation is future work.

§License

Licensed under either Apache-2.0 or MIT.

Structs§

GoExportedIdentifier
Validated exported ASCII-safe Go identifier.
GoIdentifier
Validated ASCII-safe Go identifier.
GoUnexportedIdentifier
Validated unexported ASCII-safe Go identifier.

Enums§

GoIdentifierError
Error returned when an ASCII Go identifier is invalid.

Functions§

is_ascii_go_identifier_continue
Returns whether character is accepted after the first identifier character.
is_ascii_go_identifier_start
Returns whether character is accepted as an ASCII Go identifier start.
is_exported_go_identifier
Returns whether value is an exported ASCII-safe Go identifier.
is_unexported_go_identifier
Returns whether value is an unexported ASCII-safe Go identifier.
is_valid_ascii_go_identifier
Returns whether value is an ASCII-safe Go identifier.