Skip to main content

Language

Enum Language 

Source
pub enum Language {
Show 31 variants Rust, Ocaml, C, Cpp, Go, Java, JavaScript, TypeScript, Python, Shell, Html, Css, Jsonc, Sql, Kotlin, Toml, Lua, Yaml, Php, Ruby, Zig, R, Dart, Swift, CSharp, Scala, Vue, Svelte, Markdown, Perl, Unknown,
}
Expand description

A language OComment has a built-in scanner for.

The serde representation is the canonical name Self::as_str returns. FromStr accepts that name and every spelling in Self::aliases, case-folded and with - and _ ignored, so C++, cxx and cpp all name Self::Cpp.

Variants§

§

Rust

Rust, detected from .rs.

§

Ocaml

OCaml, detected from .ml and .mli.

§

C

C, detected from .c and .h; .m selects Dialect::ObjectiveC.

§

Cpp

C++, detected from .cpp and its siblings; .mm and .cu select Dialect::ObjectiveCpp and Dialect::Cuda.

§

Go

Go, detected from .go.

§

Java

Java, detected from .java.

§

JavaScript

JavaScript, detected from .js, .mjs and .cjs; .jsx selects Dialect::Jsx.

§

TypeScript

TypeScript, detected from .ts, .mts and .cts; .tsx selects Dialect::Tsx.

§

Python

Python, detected from .py, .pyw and .pyi.

§

Shell

Shell, detected from .sh, .bash and .zsh, and from a Dockerfile or Makefile name.

§

Html

HTML, detected from .html and its siblings. <script> and <style> bodies are scanned as JavaScript and CSS.

§

Css

CSS, detected from .css.

§

Jsonc

JSON with comments, detected from .jsonc, .json5, and from a tsconfig.json or jsconfig.json name.

§

Sql

SQL, detected from .sql. The Dialect decides the string and comment rules.

§

Kotlin

Kotlin, detected from .kt and .kts.

§

Toml

TOML, detected from .toml and from the lock file names written in it, such as Cargo.lock.

§

Lua

Lua, detected from .lua and .rockspec, and from a lua or luajit #! line.

§

Yaml

YAML, detected from .yml and .yaml, and from the extensionless configuration names written in it, such as .clang-format.

§

Php

PHP, detected from .php, .phtml and .phpt, and from a php #! line. The inline HTML around the <?php ... ?> tags is content.

§

Ruby

Ruby, detected from .rb and its siblings, from the extensionless project files written in it, such as Gemfile, and from a ruby #! line.

§

Zig

Zig, detected from .zig and from the .zon of Zig Object Notation. It has no block comment: /* is two operators.

§

R

R, detected from .r in either case, from a .Rprofile name, and from an Rscript or r #! line.

§

Dart

Dart, detected from .dart and from a dart #! line. Its block comments nest.

§

Swift

Swift, detected from .swift and from a swift #! line. Its block comments nest and #/ ... /# is an opaque regular expression literal.

§

CSharp

C#, detected from .cs and from the .csx of a script. A line whose first non-blank byte is # is a preprocessor directive and carries at most a // comment.

§

Scala

Scala, detected from .scala and from the .sc of a script, and from a scala or scala-cli #! line. Its block comments nest, a string is interpolated when an identifier stands directly before its quote, and a < with the shape of an XML literal opens one.

§

Vue

Vue, detected from the .vue of a single-file component. Its template is HTML with {{ ... }} code, and its <script> and <style> bodies are scanned as their own languages, the lang attribute choosing which.

§

Svelte

Svelte, detected from the .svelte of a component. Its template is HTML with { ... } code, and its <script> and <style> bodies are scanned as their own languages.

§

Markdown

Markdown, detected from .md, .markdown and the .Rmd of an R Markdown document. HTML comments are comments, fenced code blocks are scanned as the language their info string names, and inline and indented code are opaque.

§

Perl

Perl, detected from .pl, .pm and .t, and from a perl #! line. Its quote words, here-documents and regular expressions hide a #, its POD blocks are opaque, and a / the parse context alone settles is reported as lexically ambiguous.

§

Unknown

No built-in scanner, and the default.

Scanning it yields no comments and one unknown-language error diagnostic. A syntax with no built-in scanner is handled by a DeclarativeProfile or by transform_spans instead.

Implementations§

Source§

impl Language

Source

pub const ALL: [Self; 30]

Every CLI-visible language; Unknown is deliberately excluded.

Source

pub const fn as_str(self) -> &'static str

The canonical name, identical to the serde representation.

Source

pub const fn aliases(self) -> &'static [&'static str]

Accepted spellings besides Self::as_str, already case- and separator-folded.

Trait Implementations§

Source§

impl Clone for Language

Source§

fn clone(&self) -> Language

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Language

Source§

impl Debug for Language

Source§

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

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

impl Default for Language

Source§

fn default() -> Language

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Language

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Language

Source§

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

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

impl Eq for Language

Source§

impl FromStr for Language

Source§

type Err = String

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

fn from_str(value: &str) -> Result<Self, Self::Err>

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

impl Hash for Language

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 for Language

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Language

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Language

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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> ToOwned for T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

type Error = !

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 T
where U: TryFrom<T>,

Source§

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.