pub struct UniqueNames<'a> { /* private fields */ }Expand description
Deduplicates names across case conventions.
Implementations§
Source§impl<'a> UniqueNames<'a>
impl<'a> UniqueNames<'a>
pub fn new(arena: &'a Arena) -> Self
pub fn with_reserved<S: AsRef<str>>( arena: &'a Arena, reserved: impl IntoIterator<Item = S>, ) -> Self
Sourcepub fn uniquify(&mut self, name: &str) -> &'a str
pub fn uniquify(&mut self, name: &str) -> &'a str
Adds a name to this scope and returns a unique form.
Names without word content use numeric forms starting at 1.
§Examples
let arena = Arena::new();
let mut names = UniqueNames::new(&arena);
assert_eq!(names.uniquify("HTTPResponse"), "HTTPResponse");
assert_eq!(names.uniquify("HTTP_Response"), "HTTP_Response2");
assert_eq!(names.uniquify("httpResponse"), "httpResponse3");
assert_eq!(names.uniquify("http_response_2"), "http_response4");Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for UniqueNames<'a>
impl<'a> !RefUnwindSafe for UniqueNames<'a>
impl<'a> !Send for UniqueNames<'a>
impl<'a> !Sync for UniqueNames<'a>
impl<'a> Unpin for UniqueNames<'a>
impl<'a> UnsafeUnpin for UniqueNames<'a>
impl<'a> !UnwindSafe for UniqueNames<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more