Enum tokei::LanguageType

source ·
#[non_exhaustive]
pub enum LanguageType {
Show 258 variants ABNF, AWK, Abap, ActionScript, Ada, Agda, Alex, Alloy, Arduino, AsciiDoc, Asn1, Asp, AspNet, Assembly, AssemblyGAS, Ats, AutoHotKey, Autoconf, Autoit, Automake, Bash, Batch, Bean, Bitbake, BrightScript, C, CHeader, CMake, CSharp, CShell, Cabal, Cassius, Ceylon, Clojure, ClojureC, ClojureScript, Cobol, CodeQL, CoffeeScript, Cogent, ColdFusion, ColdFusionScript, Coq, Cpp, CppHeader, Crystal, Css, Cuda, Cython, D, Daml, Dart, DeviceTree, Dhall, Dockerfile, DotNetResource, DreamMaker, Dust, Ebuild, Edn, Elisp, Elixir, Elm, Elvish, EmacsDevEnv, Emojicode, Erlang, FEN, FSharp, Factor, Fennel, Fish, FlatBuffers, ForgeConfig, Forth, FortranLegacy, FortranModern, FreeMarker, Fstar, Futhark, GDB, GdScript, Gherkin, Gleam, Glsl, Gml, Go, Gohtml, Graphql, Groovy, Gwion, Haml, Hamlet, Handlebars, Happy, Haskell, Haxe, Hcl, Headache, Hex, Hlsl, HolyC, Html, Hy, Idris, Ini, IntelHex, Isabelle, Jai, Java, JavaScript, Jinja2, Json, Jsonnet, Jsx, Julia, Julius, Jupyter, K, KakouneScript, Kotlin, Ksh, KvLanguage, LLVM, Lean, Less, LinkerScript, Liquid, Lisp, LiveScript, Logtalk, LolCode, Lua, Lucius, M4, Madlang, Makefile, Markdown, Meson, Metal, Mint, Mlatu, ModuleDef, MoonScript, MsBuild, Mustache, Nextflow, Nim, Nix, NotQuitePerl, OCaml, ObjectiveC, ObjectiveCpp, Odin, OpenPolicyAgent, OpenType, Org, Oz, PSL, Pan, Pascal, Perl, Pest, Php, Poke, Polly, Pony, PostCss, PowerShell, Processing, Prolog, Protobuf, Pug, Puppet, PureScript, Python, Q, Qcl, Qml, R, RON, RPMSpecfile, Racket, Rakefile, Raku, Razor, ReScript, ReStructuredText, Renpy, Ruby, RubyHtml, Rust, SRecode, Sass, Scala, Scheme, Scons, Sh, ShaderLab, Sml, Solidity, SpecmanE, Spice, Sqf, Sql, Stan, Stratego, Stylus, Svelte, Svg, Swift, Swig, SystemVerilog, Tcl, Tera, Tex, Text, Thrift, Toml, Tsx, Ttcn, Twig, TypeScript, UMPL, Unison, UnrealDeveloperMarkdown, UnrealPlugin, UnrealProject, UnrealScript, UnrealShader, UnrealShaderHeader, UrWeb, UrWebProject, VB6, VBScript, Vala, Velocity, Verilog, VerilogArgsFile, Vhdl, VimScript, VisualBasic, VisualStudioProject, VisualStudioSolution, Vue, WGSL, WebAssembly, WenYan, Wolfram, XSL, Xaml, XcodeConfig, Xml, Xtend, Yaml, ZenCode, Zig, Zsh,
}
Expand description

Represents a individual programming language. Can be used to provide information about the language, such as multi line comments, single line comments, string literal syntax, whether a given language allows nesting comments.

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.
§

ABNF

§

AWK

§

Abap

§

ActionScript

§

Ada

§

Agda

§

Alex

§

Alloy

§

Arduino

§

AsciiDoc

§

Asn1

§

Asp

§

AspNet

§

Assembly

§

AssemblyGAS

§

Ats

§

AutoHotKey

§

Autoconf

§

Autoit

§

Automake

§

Bash

§

Batch

§

Bean

§

Bitbake

§

BrightScript

§

C

§

CHeader

§

CMake

§

CSharp

§

CShell

§

Cabal

§

Cassius

§

Ceylon

§

Clojure

§

ClojureC

§

ClojureScript

§

Cobol

§

CodeQL

§

CoffeeScript

§

Cogent

§

ColdFusion

§

ColdFusionScript

§

Coq

§

Cpp

§

CppHeader

§

Crystal

§

Css

§

Cuda

§

Cython

§

D

§

Daml

§

Dart

§

DeviceTree

§

Dhall

§

Dockerfile

§

DotNetResource

§

DreamMaker

§

Dust

§

Ebuild

§

Edn

§

Elisp

§

Elixir

§

Elm

§

Elvish

§

EmacsDevEnv

§

Emojicode

§

Erlang

§

FEN

§

FSharp

§

Factor

§

Fennel

§

Fish

§

FlatBuffers

§

ForgeConfig

§

Forth

§

FortranLegacy

§

FortranModern

§

FreeMarker

§

Fstar

§

Futhark

§

GDB

§

GdScript

§

Gherkin

§

Gleam

§

Glsl

§

Gml

§

Go

§

Gohtml

§

Graphql

§

Groovy

§

Gwion

§

Haml

§

Hamlet

§

Handlebars

§

Happy

§

Haskell

§

Haxe

§

Hcl

§

Headache

§

Hex

§

Hlsl

§

HolyC

§

Html

§

Hy

§

Idris

§

Ini

§

IntelHex

§

Isabelle

§

Jai

§

Java

§

JavaScript

§

Jinja2

§

Json

§

Jsonnet

§

Jsx

§

Julia

§

Julius

§

Jupyter

§

K

§

KakouneScript

§

Kotlin

§

Ksh

§

KvLanguage

§

LLVM

§

Lean

§

Less

§

LinkerScript

§

Liquid

§

Lisp

§

LiveScript

§

Logtalk

§

LolCode

§

Lua

§

Lucius

§

M4

§

Madlang

§

Makefile

§

Markdown

§

Meson

§

Metal

§

Mint

§

Mlatu

§

ModuleDef

§

MoonScript

§

MsBuild

§

Mustache

§

Nextflow

§

Nim

§

Nix

§

NotQuitePerl

§

OCaml

§

ObjectiveC

§

ObjectiveCpp

§

Odin

§

OpenPolicyAgent

§

OpenType

§

Org

§

Oz

§

PSL

§

Pan

§

Pascal

§

Perl

§

Pest

§

Php

§

Poke

§

Polly

§

Pony

§

PostCss

§

PowerShell

§

Processing

§

Prolog

§

Protobuf

§

Pug

§

Puppet

§

PureScript

§

Python

§

Q

§

Qcl

§

Qml

§

R

§

RON

§

RPMSpecfile

§

Racket

§

Rakefile

§

Raku

§

Razor

§

ReScript

§

ReStructuredText

§

Renpy

§

Ruby

§

RubyHtml

§

Rust

§

SRecode

§

Sass

§

Scala

§

Scheme

§

Scons

§

Sh

§

ShaderLab

§

Sml

§

Solidity

§

SpecmanE

§

Spice

§

Sqf

§

Sql

§

Stan

§

Stratego

§

Stylus

§

Svelte

§

Svg

§

Swift

§

Swig

§

SystemVerilog

§

Tcl

§

Tera

§

Tex

§

Text

§

Thrift

§

Toml

§

Tsx

§

Ttcn

§

Twig

§

TypeScript

§

UMPL

§

Unison

§

UnrealDeveloperMarkdown

§

UnrealPlugin

§

UnrealProject

§

UnrealScript

§

UnrealShader

§

UnrealShaderHeader

§

UrWeb

§

UrWebProject

§

VB6

§

VBScript

§

Vala

§

Velocity

§

Verilog

§

VerilogArgsFile

§

Vhdl

§

VimScript

§

VisualBasic

§

VisualStudioProject

§

VisualStudioSolution

§

Vue

§

WGSL

§

WebAssembly

§

WenYan

§

Wolfram

§

XSL

§

Xaml

§

XcodeConfig

§

Xml

§

Xtend

§

Yaml

§

ZenCode

§

Zig

§

Zsh

Implementations§

source§

impl LanguageType

source

pub fn name(self) -> &'static str

Returns the display name of a language.

let bash = LanguageType::Bash;

assert_eq!(bash.name(), "BASH");
source

pub fn is_literate(self) -> bool

Returns whether the language is “literate”, meaning that it considered to primarily be documentation and is counted primarily as comments rather than procedural code.

source

pub fn list() -> &'static [(Self, &'static [&'static str])]

Provides every variant in a Vec

source

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

Returns the single line comments of a language.

use tokei::LanguageType;
let lang = LanguageType::Rust;
assert_eq!(lang.line_comments(), &["//"]);
source

pub fn multi_line_comments(self) -> &'static [(&'static str, &'static str)]

Returns the single line comments of a language.

use tokei::LanguageType;
let lang = LanguageType::Rust;
assert_eq!(lang.multi_line_comments(), &[("/*", "*/")]);
source

pub fn allows_nested(self) -> bool

Returns whether the language allows nested multi line comments.

use tokei::LanguageType;
let lang = LanguageType::Rust;
assert!(lang.allows_nested());
source

pub fn nested_comments(self) -> &'static [(&'static str, &'static str)]

Returns what nested comments the language has. (Currently only D has any of this type.)

use tokei::LanguageType;
let lang = LanguageType::D;
assert_eq!(lang.nested_comments(), &[("/+", "+/")]);
source

pub fn quotes(self) -> &'static [(&'static str, &'static str)]

Returns the quotes of a language.

use tokei::LanguageType;
let lang = LanguageType::C;
assert_eq!(lang.quotes(), &[("\"", "\"")]);
source

pub fn verbatim_quotes(self) -> &'static [(&'static str, &'static str)]

Returns the verbatim quotes of a language.

use tokei::LanguageType;
let lang = LanguageType::CSharp;
assert_eq!(lang.verbatim_quotes(), &[("@\"", "\"")]);
source

pub fn doc_quotes(self) -> &'static [(&'static str, &'static str)]

Returns the doc quotes of a language.

use tokei::LanguageType;
let lang = LanguageType::Python;
assert_eq!(lang.doc_quotes(), &[("\"\"\"", "\"\"\""), ("'''", "'''")]);
source

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

Returns the shebang of a language.

use tokei::LanguageType;
let lang = LanguageType::Bash;
assert_eq!(lang.shebangs(), &["#!/bin/bash"]);
source

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

Returns the parts of syntax that determines whether tokei can skip large parts of analysis.

source

pub fn from_path<P: AsRef<Path>>(entry: P, _config: &Config) -> Option<Self>

Get language from a file path. May open and read the file.

use tokei::{Config, LanguageType};

let rust = LanguageType::from_path("./main.rs", &Config::default());

assert_eq!(rust, Some(LanguageType::Rust));
source

pub fn from_file_extension(extension: &str) -> Option<Self>

Get language from a file extension.

use tokei::LanguageType;

let rust = LanguageType::from_file_extension("rs");

assert_eq!(rust, Some(LanguageType::Rust));
source

pub fn from_mime(mime: &str) -> Option<Self>

Get language from its MIME type if available.

use tokei::LanguageType;

let lang = LanguageType::from_mime("application/javascript");

assert_eq!(lang, Some(LanguageType::JavaScript));
source

pub fn from_shebang<P: AsRef<Path>>(entry: P) -> Option<Self>

Get language from a shebang. May open and read the file.

use tokei::LanguageType;

let rust = LanguageType::from_shebang("./main.rs");

assert_eq!(rust, Some(LanguageType::Rust));
source§

impl LanguageType

source

pub fn parse( self, path: PathBuf, config: &Config ) -> Result<Report, (Error, PathBuf)>

Parses a given Path using the LanguageType. Returning Report on success and giving back ownership of PathBuf on error.

source

pub fn parse_from_str<A: AsRef<str>>( self, text: A, config: &Config ) -> CodeStats

Parses the text provided as the given LanguageType.

source

pub fn parse_from_slice<A: AsRef<[u8]>>( self, text: A, config: &Config ) -> CodeStats

Parses the bytes provided as the given LanguageType.

Trait Implementations§

source§

impl<'arbitrary> Arbitrary<'arbitrary> for LanguageType

source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for LanguageType

source§

fn clone(&self) -> LanguageType

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 LanguageType

source§

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

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

impl<'de> Deserialize<'de> for LanguageType

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 LanguageType

source§

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

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

impl<'a> From<&'a LanguageType> for Cow<'a, LanguageType>

source§

fn from(from: &'a LanguageType) -> Self

Converts to this type from the input type.
source§

impl<'a> From<LanguageType> for Cow<'a, LanguageType>

source§

fn from(from: LanguageType) -> Self

Converts to this type from the input type.
source§

impl FromStr for LanguageType

§

type Err = &'static str

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

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

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

impl Hash for LanguageType

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 Ord for LanguageType

source§

fn cmp(&self, other: &LanguageType) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<LanguageType> for LanguageType

source§

fn eq(&self, other: &LanguageType) -> 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 PartialOrd<LanguageType> for LanguageType

source§

fn partial_cmp(&self, other: &LanguageType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for LanguageType

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 Copy for LanguageType

source§

impl Eq for LanguageType

source§

impl StructuralEq for LanguageType

source§

impl StructuralPartialEq for LanguageType

Auto Trait Implementations§

Blanket Implementations§

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> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
source§

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