pub struct CowIdentifier<'a>(/* private fields */);Expand description
A copy-on-write identifier that borrows static strings without allocation.
Use this when identifiers are often string literals but occasionally need to be dynamically generated.
§Examples
use prax_query::builder::CowIdentifier;
// Static string - zero allocation
let id = CowIdentifier::borrowed("user_id");
// Dynamic string - allocates if not static
let dynamic_name = format!("col_{}", 1);
let id = CowIdentifier::owned(dynamic_name);Implementations§
Source§impl<'a> CowIdentifier<'a>
impl<'a> CowIdentifier<'a>
Sourcepub const fn borrowed(s: &'a str) -> Self
pub const fn borrowed(s: &'a str) -> Self
Create from a borrowed static string (zero allocation).
Sourcepub fn is_borrowed(&self) -> bool
pub fn is_borrowed(&self) -> bool
Check if this is a borrowed (non-allocating) reference.
Sourcepub fn into_owned(self) -> String
pub fn into_owned(self) -> String
Convert to owned, cloning if necessary.
Trait Implementations§
Source§impl<'a> AsRef<str> for CowIdentifier<'a>
impl<'a> AsRef<str> for CowIdentifier<'a>
Source§impl<'a> Clone for CowIdentifier<'a>
impl<'a> Clone for CowIdentifier<'a>
Source§fn clone(&self) -> CowIdentifier<'a>
fn clone(&self) -> CowIdentifier<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a> Debug for CowIdentifier<'a>
impl<'a> Debug for CowIdentifier<'a>
Source§impl<'a> Default for CowIdentifier<'a>
impl<'a> Default for CowIdentifier<'a>
Source§impl<'a> Display for CowIdentifier<'a>
impl<'a> Display for CowIdentifier<'a>
Source§impl<'a> From<&'a str> for CowIdentifier<'a>
impl<'a> From<&'a str> for CowIdentifier<'a>
Source§impl From<String> for CowIdentifier<'static>
impl From<String> for CowIdentifier<'static>
Source§impl<'a> Hash for CowIdentifier<'a>
impl<'a> Hash for CowIdentifier<'a>
Source§impl<'a> PartialEq for CowIdentifier<'a>
impl<'a> PartialEq for CowIdentifier<'a>
impl<'a> Eq for CowIdentifier<'a>
impl<'a> StructuralPartialEq for CowIdentifier<'a>
Auto Trait Implementations§
impl<'a> Freeze for CowIdentifier<'a>
impl<'a> RefUnwindSafe for CowIdentifier<'a>
impl<'a> Send for CowIdentifier<'a>
impl<'a> Sync for CowIdentifier<'a>
impl<'a> Unpin for CowIdentifier<'a>
impl<'a> UnwindSafe for CowIdentifier<'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