Struct winrt::FastHString
source · pub struct FastHString(_);
Expand description
A string type that should be used to create strings that can be passed to Windows Runtime
functions. Creating a new FastHString
is faster than creating an instance of HString
because it eliminates an additional allocation. Furthermore, obtaining a HStringArg
from
a FastHString
is basically free, which is not the case for HString
.
Implementations§
source§impl FastHString
impl FastHString
sourcepub fn new(s: &str) -> FastHString
pub fn new(s: &str) -> FastHString
Creates a new FastHString
from a Rust string. FastHString
uses the Rust allocator to
create a storage buffer for its contents, where the string is stored in UTF-16 encoding.
The buffer is freed on when the FastHString
is dropped.
Examples
Basic usage:
use winrt::FastHString;
let s = FastHString::new("hello");
assert_eq!("hello", s.to_string());
sourcepub fn empty() -> FastHString
pub fn empty() -> FastHString
Creates an empty FastHString
.
sourcepub fn len(&self) -> u32
pub fn len(&self) -> u32
Returns the length of the string in Unicode characters, as specified by WindowsGetStringLen
.
Examples
Basic usage:
use winrt::FastHString;
let s = FastHString::new("hello");
assert_eq!(5, s.len());
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Checks whether the string is empty.
Examples
Basic usage:
use winrt::FastHString;
let s = FastHString::empty();
assert!(s.is_empty());
sourcepub fn make_reference(&self) -> HStringReference<'_>
pub fn make_reference(&self) -> HStringReference<'_>
Creates an HStringReference
that points to the contents of this FastHString
.
Examples
Basic usage:
use winrt::FastHString;
let s = FastHString::new("hello");
let r = s.make_reference();
assert_eq!("hello", r.to_string());
Methods from Deref<Target = HStringArg>§
Trait Implementations§
source§impl<'a> Deref for FastHString
impl<'a> Deref for FastHString
§type Target = HStringArg
type Target = HStringArg
source§fn deref(&self) -> &HStringArg
fn deref(&self) -> &HStringArg
source§impl Display for FastHString
impl Display for FastHString
source§impl Drop for FastHString
impl Drop for FastHString
source§impl<'a> From<&'a str> for FastHString
impl<'a> From<&'a str> for FastHString
source§impl Ord for FastHString
impl Ord for FastHString
source§impl<'a> PartialEq<&'a FastHString> for HString
impl<'a> PartialEq<&'a FastHString> for HString
source§fn eq(&self, other: &&'a FastHString) -> bool
fn eq(&self, other: &&'a FastHString) -> bool
source§impl PartialEq<FastHString> for FastHString
impl PartialEq<FastHString> for FastHString
source§impl PartialEq<FastHString> for HString
impl PartialEq<FastHString> for HString
source§fn eq(&self, other: &FastHString) -> bool
fn eq(&self, other: &FastHString) -> bool
source§impl<'a> PartialEq<FastHString> for HStringReference<'a>
impl<'a> PartialEq<FastHString> for HStringReference<'a>
source§fn eq(&self, other: &FastHString) -> bool
fn eq(&self, other: &FastHString) -> bool
source§impl<'a> PartialEq<HStringReference<'a>> for FastHString
impl<'a> PartialEq<HStringReference<'a>> for FastHString
source§fn eq(&self, other: &HStringReference<'_>) -> bool
fn eq(&self, other: &HStringReference<'_>) -> bool
source§impl PartialOrd<FastHString> for FastHString
impl PartialOrd<FastHString> for FastHString
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more