#[non_exhaustive]
pub enum Lang {
Show 27 variants Asm, C, CSharp, Comment, Cpp, Css, Ebnf, Ejs, Erb, Go, Hexdump, Java, Javascript, Json, Lua, Markdown, MarkdownInline, Ocaml, OcamlInterface, Python, Regex, Ruby, Rush, Rust, Scala, Toml, Ursa,
}
Expand description

An enum of every supported language in the current feature set.

An instance of the respective tree-stter Language can be obtained with the get method.

You can also get a Lang from its name using for_name, or for a FileType using for_file_type. See the docs for each variant to see its “name” and the supported file types. Both of these require the SupportedLanguage trait to be in scope.

See LANGUAGES for a list containing all variants and LANGUAGE_NAMES for a list of all valid names.

The enum is marked as non-exhaustive for two reasons:

  1. New languages may be added in the future
  2. The variants are enabled/disabled by features

Example

use syntastica_parsers::{Lang, LANGUAGES, LANGUAGE_NAMES};
use syntastica_core::language_set::{SupportedLanguage, FileType};

// you can get a `Lang` from its name
assert_eq!(Lang::Rust, Lang::for_name("rust").unwrap());
// and for a file type
assert_eq!(Some(Lang::Rust), Lang::for_file_type(FileType::Rust));

// `LANGUAGES` is a list of all variants,
// `LANGUAGE_NAMES` is a list of all variant names
for (&lang, &name) in LANGUAGES.iter().zip(LANGUAGE_NAMES) {
    assert_eq!(lang, Lang::for_name(name).unwrap());

    // `Lang` instances can be turned into strings
    assert_eq!(lang, Lang::for_name(lang.name()).unwrap());
    assert_eq!(lang, Lang::for_name(lang.to_string()).unwrap());
    assert_eq!(lang, Lang::for_name(lang.as_ref()).unwrap());
    let lang_name: &'static str = lang.into();
    assert_eq!(lang, Lang::for_name(lang_name).unwrap());
}

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Asm

Available on crate features most or asm only.

Provides the asm language, supports these file types: asm, vmasm.

§

C

Available on crate features some or c only.

Provides the c language, supports these file types: c.

§

CSharp

Available on crate features most or c_sharp only.

Provides the c_sharp language, supports these file types: csharp.

§

Comment

Available on crate features most or comment only.

Provides the comment language, supports no file types.

§

Cpp

Available on (crate features some or cpp) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the cpp language, supports these file types: cpp.

§

Css

Available on crate features some or css only.

Provides the css language, supports these file types: css.

§

Ebnf

Available on crate features all or ebnf only.

Provides the ebnf language, supports these file types: ebnf.

§

Ejs

Available on crate features all or ejs only.

Provides the ejs language, supports these file types: ejavascript.

§

Erb

Available on crate features all or erb only.

Provides the erb language, supports these file types: eruby.

§

Go

Available on crate features some or go only.

Provides the go language, supports these file types: go.

§

Hexdump

Available on crate features all or hexdump only.

Provides the hexdump language, supports these file types: hexdump.

§

Java

Available on crate features some or java only.

Provides the java language, supports these file types: java.

§

Javascript

Available on crate features some or javascript only.

Provides the javascript language, supports these file types: javascript, jsx.

§

Json

Available on crate features some or json only.

Provides the json language, supports these file types: json.

§

Lua

Available on (crate features some or lua) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the lua language, supports these file types: lua.

§

Markdown

Available on (crate features most or markdown) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the markdown language, supports these file types: markdown.

§

MarkdownInline

Available on (crate features most or markdown_inline) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the markdown_inline language, supports these file types: markdown.

§

Ocaml

Available on (crate features all or ocaml) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the ocaml language, supports these file types: ocaml.

§

OcamlInterface

Available on (crate features all or ocaml_interface) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the ocaml_interface language, supports these file types: ocamlinterface.

§

Python

Available on (crate features some or python) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the python language, supports these file types: python.

§

Regex

Available on crate features most or regex only.

Provides the regex language, supports no file types.

§

Ruby

Available on (crate features most or ruby) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the ruby language, supports these file types: ruby.

§

Rush

Available on crate features all or rush only.

Provides the rush language, supports these file types: rush.

§

Rust

Available on crate features some or rust only.

Provides the rust language, supports these file types: rust.

§

Scala

Available on (crate features most or scala) and not (WebAssembly and target_vendor="unknown" and target_os="unknown" and target_env="") only.

Provides the scala language, supports these file types: scala, sbt.

§

Toml

Available on crate features some or toml only.

Provides the toml language, supports these file types: toml.

§

Ursa

Available on crate features all or ursa only.

Provides the ursa language, supports these file types: ursa.

Implementations§

source§

impl Lang

source

pub fn get(&self) -> Language

Get an instance of the respective Language.

Trait Implementations§

source§

impl AsRef<str> for Lang

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Lang

source§

fn clone(&self) -> Lang

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Lang

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Lang

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'_derivative_strum> From<&'_derivative_strum Lang> for &'static str

source§

fn from(x: &'_derivative_strum Lang) -> &'static str

Converts to this type from the input type.
source§

impl From<Lang> for &'static str

source§

fn from(x: Lang) -> &'static str

Converts to this type from the input type.
source§

impl FromStr for Lang

§

type Err = ParseError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Lang, <Self as FromStr>::Err>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Lang

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl PartialEq<Lang> for Lang

source§

fn eq(&self, other: &Lang) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl SupportedLanguage for Lang

source§

fn name(&self) -> Cow<'_, str>

Get the name for this language. Read more
source§

fn for_name(name: impl AsRef<str>) -> Result<Self>

Get the language with the given name. Read more
source§

fn for_file_type(file_type: FileType) -> Option<Self>

Find a language based on the given [FileType]. Read more
§

fn for_injection(name: impl AsRef<str>) -> Option<Self>

Find a language for an injection. Read more
source§

impl TryFrom<&str> for Lang

§

type Error = ParseError

The type returned in the event of a conversion error.
source§

fn try_from(s: &str) -> Result<Lang, <Self as TryFrom<&str>>::Error>

Performs the conversion.
source§

impl Copy for Lang

source§

impl Eq for Lang

source§

impl StructuralEq for Lang

source§

impl StructuralPartialEq for Lang

Auto Trait Implementations§

§

impl RefUnwindSafe for Lang

§

impl Send for Lang

§

impl Sync for Lang

§

impl Unpin for Lang

§

impl UnwindSafe for Lang

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<T>,

Convert the source color to the destination color using the specified method.
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default.
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T, C> ArraysFrom<C> for Twhere C: IntoArrays<T>,

source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
source§

impl<T, C> ArraysInto<C> for Twhere C: FromArrays<T>,

source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, C> ComponentsFrom<C> for Twhere C: IntoComponents<T>,

source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromAngle<T> for T

source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
source§

impl<T, U> FromStimulus<U> for Twhere U: IntoStimulus<T>,

source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> IntoAngle<U> for Twhere U: FromAngle<T>,

source§

fn into_angle(self) -> U

Performs a conversion into T.
source§

impl<T, U> IntoColor<U> for Twhere U: FromColor<T>,

source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,

source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
source§

impl<T> IntoStimulus<T> for T

source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<'a, T, C> TryComponentsInto<C> for Twhere C: TryFromComponents<T>,

§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,

source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
source§

impl<C, U> UintsFrom<C> for Uwhere C: IntoUints<U>,

source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
source§

impl<C, U> UintsInto<C> for Uwhere C: FromUints<U>,

source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.