#[repr(C)]pub struct String { /* private fields */ }Expand description
Binding to the string type used by Neovim.
Unlike Rust’s String, this type is not guaranteed to contain valid UTF-8
byte sequences, it can contain null bytes, and it is null-terminated.
Implementations§
Source§impl String
impl String
pub fn as_bytes(&self) -> &[u8] ⓘ
Sourcepub fn as_nvim_str(&self) -> NvimStr<'_>
pub fn as_nvim_str(&self) -> NvimStr<'_>
Returns an NvimStr view of this String.
Sourcepub fn from_bytes(bytes: &[u8]) -> String
pub fn from_bytes(bytes: &[u8]) -> String
Creates a String from a byte slice by allocating bytes.len() + 1
bytes of memory and copying the contents of bytes into it, followed
by a null byte.
Sourcepub unsafe fn from_raw_parts(data: *const i8, len: usize) -> String
pub unsafe fn from_raw_parts(data: *const i8, len: usize) -> String
Creates a String from a pointer to the underlying data and a length.
§Safety
The caller must ensure that the pointer is valid for len + 1
elements and that the last element is a null byte.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the length of the String, not including the final null
byte.
Sourcepub fn to_str(&self) -> Result<&str, Utf8Error>
pub fn to_str(&self) -> Result<&str, Utf8Error>
Yields a string slice if the String’s contents are valid UTF-8.
Sourcepub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Converts the String into Rust’s std::string::String. If it already
holds a valid UTF-8 byte sequence no allocation is made. If it doesn’t
the String is copied and all invalid sequences are replaced with �.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for String
impl<'de> Deserialize<'de> for String
Source§fn deserialize<D>(
deserializer: D,
) -> Result<String, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<String, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl From<ContextType> for String
impl From<ContextType> for String
Source§fn from(ctx: ContextType) -> String
fn from(ctx: ContextType) -> String
Source§impl From<ExtmarkHlMode> for String
impl From<ExtmarkHlMode> for String
Source§fn from(mode: ExtmarkHlMode) -> String
fn from(mode: ExtmarkHlMode) -> String
Source§impl From<ExtmarkVirtTextPosition> for String
impl From<ExtmarkVirtTextPosition> for String
Source§fn from(pos: ExtmarkVirtTextPosition) -> String
fn from(pos: ExtmarkVirtTextPosition) -> String
Source§impl From<MouseAction> for String
impl From<MouseAction> for String
Source§fn from(action: MouseAction) -> String
fn from(action: MouseAction) -> String
Source§impl From<MouseButton> for String
impl From<MouseButton> for String
Source§fn from(action: MouseButton) -> String
fn from(action: MouseButton) -> String
Source§impl From<OptionScope> for String
impl From<OptionScope> for String
Source§fn from(ctx: OptionScope) -> String
fn from(ctx: OptionScope) -> String
Source§impl From<RegisterType> for String
impl From<RegisterType> for String
Source§fn from(reg_type: RegisterType) -> String
fn from(reg_type: RegisterType) -> String
Source§impl From<SplitDirection> for String
impl From<SplitDirection> for String
Source§fn from(direction: SplitDirection) -> String
fn from(direction: SplitDirection) -> String
Source§impl From<VirtLinesOverflow> for String
impl From<VirtLinesOverflow> for String
Source§fn from(virt_lines_overflow: VirtLinesOverflow) -> String
fn from(virt_lines_overflow: VirtLinesOverflow) -> String
Source§impl From<WindowAnchor> for String
impl From<WindowAnchor> for String
Source§fn from(anchor: WindowAnchor) -> String
fn from(anchor: WindowAnchor) -> String
Source§impl From<WindowRelativeTo> for String
impl From<WindowRelativeTo> for String
Source§fn from(pos: WindowRelativeTo) -> String
fn from(pos: WindowRelativeTo) -> String
Source§impl From<WindowStyle> for String
impl From<WindowStyle> for String
Source§fn from(style: WindowStyle) -> String
fn from(style: WindowStyle) -> String
Source§impl From<WindowTitlePosition> for String
impl From<WindowTitlePosition> for String
Source§fn from(pos: WindowTitlePosition) -> String
fn from(pos: WindowTitlePosition) -> String
Source§impl Ord for String
impl Ord for String
Source§impl PartialOrd for String
impl PartialOrd for String
impl Eq for String
impl StructuralPartialEq for String
Auto Trait Implementations§
impl Freeze for String
impl RefUnwindSafe for String
impl !Send for String
impl !Sync for String
impl Unpin for String
impl UnwindSafe for String
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<T> FromObject for T
impl<T> FromObject for T
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§type Error = Infallible
type Error = Infallible
Result.Source§fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
fn into_result(self) -> Result<T, <T as IntoResult<T>>::Error>
Result.