pub struct UniqueNamesScope<'a> { /* private fields */ }Expand description
A scope for unique names.
Implementations§
Source§impl<'a> UniqueNamesScope<'a>
impl<'a> UniqueNamesScope<'a>
Sourcepub fn uniquify<'b>(&mut self, name: &'b str) -> Cow<'b, str>
pub fn uniquify<'b>(&mut self, name: &'b str) -> Cow<'b, str>
Adds a name to this scope. If the name doesn’t exist within this scope yet, returns the name as-is; otherwise, returns the name with a unique numeric suffix.
§Examples
let unique = UniqueNames::new();
let mut scope = unique.scope();
assert_eq!(scope.uniquify("HTTPResponse"), "HTTPResponse");
assert_eq!(scope.uniquify("HTTP_Response"), "HTTP_Response2");
assert_eq!(scope.uniquify("httpResponse"), "httpResponse3");Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for UniqueNamesScope<'a>
impl<'a> !RefUnwindSafe for UniqueNamesScope<'a>
impl<'a> !Send for UniqueNamesScope<'a>
impl<'a> !Sync for UniqueNamesScope<'a>
impl<'a> Unpin for UniqueNamesScope<'a>
impl<'a> !UnwindSafe for UniqueNamesScope<'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