[−][src]Enum lsp_msg_internal::Elective
Represents an optional field of an LSP object.
Is useful where an absent field represents functionality different from the default functionality of the field.
Specifications
SPEC-Elective-serde
Elective
shall implement theDeserialize
andSerialize
traits to differentiate between an absent field and a present field.
use lsp_msg_internal::Elective; use serde_test::{assert_tokens, Token}; assert_tokens(&Elective::<u8>::Absent, &[Token::Unit]); assert_tokens(&Elective::Present(0_u8), &[Token::U8(0)]);
Variants
Absent
Indicates a missing field.
Present(T)
Indicates a present field.
Methods
impl<T> Elective<T>
[src]
Specifications
SPEC-Elective-absent
Elective
shall implement the functionality to check if an instance is absent.
use lsp_msg_internal::Elective; assert!(Elective::<u8>::Absent.is_absent()); assert!(!Elective::Present(0).is_absent());
Trait Implementations
impl<T: PartialEq> PartialEq<Elective<T>> for Elective<T>
[src]
impl<T> Default for Elective<T>
[src]
Specifications
SPEC-Elective-default
Elective
shall implement theDefault
trait to return an absent field.
use lsp_msg_internal::Elective; assert!(Elective::<u8>::default().is_absent())
impl<T: Debug> Debug for Elective<T>
[src]
impl<T> Serialize for Elective<T> where
T: Serialize,
[src]
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<'de, T> Deserialize<'de> for Elective<T> where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,