pub struct NameKey { /* private fields */ }Expand description
An object name that compares, hashes, and orders case-insensitively while preserving the original casing for display.
The folded form is computed once at construction, so equality and hashing are plain string operations on a precomputed field.
std::borrow::Borrow<str> is deliberately not implemented: Borrow requires
that the borrowed value hash and compare identically to the owner, which cannot hold
when Eq/Hash use folded while as_str yields original.
§Examples
use ripbi_core::NameKey;
// Case is irrelevant to identity, in ASCII and beyond.
assert_eq!(NameKey::new("Sales"), NameKey::new("SALES"));
assert_eq!(NameKey::new("MÅNED"), NameKey::new("måned"));
// ...but the model's own casing survives for display.
assert_eq!(NameKey::new("SaLeS").as_str(), "SaLeS");Implementations§
Source§impl NameKey
impl NameKey
Sourcepub fn new(name: impl Into<String>) -> Self
pub fn new(name: impl Into<String>) -> Self
Creates a key from a name as written in the source model.
Sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
The name with its original casing, as written in the source model.
Sourcepub fn quoted(&self) -> impl Display + '_
pub fn quoted(&self) -> impl Display + '_
Writes the name as a single-quoted DAX identifier, doubling any internal
quote — the same form ObjectId and FieldRef display table names in.
§Examples
use ripbi_core::NameKey;
assert_eq!(NameKey::new("Sales").quoted().to_string(), "'Sales'");
assert_eq!(NameKey::new("O'Brien").quoted().to_string(), "'O''Brien'");Trait Implementations§
impl Eq for NameKey
Source§impl Ord for NameKey
impl Ord for NameKey
Source§fn cmp(&self, other: &Self) -> Ordering
fn cmp(&self, other: &Self) -> Ordering
Orders by the folded form only. Tie-breaking on original would make two
Eq keys compare as Less/Greater, violating the Ord/Eq consistency
contract that BTreeMap and sort rely on.
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Auto Trait Implementations§
impl Freeze for NameKey
impl RefUnwindSafe for NameKey
impl Send for NameKey
impl Sync for NameKey
impl Unpin for NameKey
impl UnsafeUnpin for NameKey
impl UnwindSafe for NameKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.