pub enum Language {
Go,
Java,
Kotlin,
Python,
Ruby,
Rust,
}Expand description
A programming language supported by pelicode.
Variants§
Go
Go (.go).
Java
Java (.java).
Kotlin
Kotlin (.kt, .kts).
Python
Python (.py).
Ruby
Ruby (.rb).
Rust
Rust (.rs).
Implementations§
Source§impl Language
impl Language
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Lower-case name of the language, as used in databases and reports.
§Examples
use pelicode_core::Language;
assert_eq!(Language::Kotlin.name(), "kotlin");
assert_eq!("kotlin".parse::<Language>(), Ok(Language::Kotlin));Sourcepub fn extensions(self) -> &'static [&'static str]
pub fn extensions(self) -> &'static [&'static str]
File extensions of the language, without the leading dot.
§Examples
use pelicode_core::Language;
assert_eq!(Language::Kotlin.extensions(), ["kt", "kts"]);Sourcepub fn from_extension(ext: &str) -> Option<Language>
pub fn from_extension(ext: &str) -> Option<Language>
The language of a file extension (without the dot); None when unsupported.
§Examples
use pelicode_core::Language;
assert_eq!(Language::from_extension("rs"), Some(Language::Rust));
assert_eq!(Language::from_extension("c"), None);Sourcepub fn from_path(path: &Path) -> Option<Language>
pub fn from_path(path: &Path) -> Option<Language>
The language of a file, from its extension; None when unsupported.
§Examples
use std::path::Path;
use pelicode_core::Language;
assert_eq!(Language::from_path(Path::new("src/Main.java")), Some(Language::Java));
assert_eq!(Language::from_path(Path::new("README.md")), None);Sourcepub fn ts_language(self) -> Language
pub fn ts_language(self) -> Language
The Tree-sitter grammar of the language.
§Examples
use pelicode_core::Language;
let mut parser = tree_sitter::Parser::new();
parser.set_language(&Language::Go.ts_language()).unwrap();
let tree = parser.parse("package main", None).unwrap();
assert_eq!(tree.root_node().kind(), "source_file");Trait Implementations§
impl Copy for Language
Source§impl<'de> Deserialize<'de> for Language
impl<'de> Deserialize<'de> for Language
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Language
Source§impl Ord for Language
impl Ord for Language
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Language
impl PartialOrd for Language
impl StructuralPartialEq for Language
Auto Trait Implementations§
impl Freeze for Language
impl RefUnwindSafe for Language
impl Send for Language
impl Sync for Language
impl Unpin for Language
impl UnsafeUnpin for Language
impl UnwindSafe for Language
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more