[][src]Enum lsp_msg_internal::Elective

pub enum Elective<T> {
    Absent,
    Present(T),
}

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 the Deserialize and Serialize 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());

pub fn is_absent(&self) -> bool[src]

If the Elective 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 the Default 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]

impl<'de, T> Deserialize<'de> for Elective<T> where
    T: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<T> Send for Elective<T> where
    T: Send

impl<T> Sync for Elective<T> where
    T: Sync

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]