[][src]Struct tokei::Language

pub struct Language {
    pub blanks: usize,
    pub code: usize,
    pub comments: usize,
    pub reports: Vec<Report>,
    pub children: BTreeMap<LanguageType, Vec<Report>>,
    pub inaccurate: bool,
}

A struct representing statistics about a single Language.

Fields

blanks: usize

The total number of blank lines.

code: usize

The total number of lines of code.

comments: usize

The total number of comments(both single, and multi-line)

reports: Vec<Report>

A collection of statistics of individual files.

children: BTreeMap<LanguageType, Vec<Report>>

A map of any languages found in the reports.

inaccurate: bool

Whether this language had problems with file parsing

Implementations

impl Language[src]

pub fn new() -> Self[src]

Constructs a new empty Language with the comments provided.

let mut rust = Language::new();

pub fn lines(&self) -> usize[src]

Returns the total number of lines.

pub fn add_report(&mut self, report: Report)[src]

Add a Report to the Language. This will not update the totals in the Language struct.

pub fn mark_inaccurate(&mut self)[src]

Marks this language as possibly not reflecting correct stats.

pub fn summarise(&self) -> Language[src]

Creates a new Language from self, which is a summarised version of the language that doesn't contain any children. It will count non-blank lines in child languages as code unless the child language is considered "literate" then it will be counted as comments.

pub fn total(&mut self)[src]

Totals up the statistics of the Stat structs currently contained in the language.

use std::{collections::BTreeMap, path::PathBuf};
use tokei::Language;

let mut language = Language::new();

// Add stats...

assert_eq!(0, language.lines());

language.total();

assert_eq!(10, language.lines());

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

Checks if the language is empty. Empty meaning it doesn't have any statistics.

let rust = Language::new();

assert!(rust.is_empty());

pub fn sort_by(&mut self, category: Sort)[src]

Sorts each of the Reports contained in the language based on what category is provided.

use std::{collections::BTreeMap, path::PathBuf};
use tokei::{Language, Sort};

let mut language = Language::new();

// Add stats...

language.sort_by(Sort::Lines);
assert_eq!(20, language.reports[0].stats.lines());

language.sort_by(Sort::Code);
assert_eq!(8, language.reports[0].stats.code);

Trait Implementations

impl AddAssign<Language> for Language[src]

impl Clone for Language[src]

impl Debug for Language[src]

impl Default for Language[src]

impl<'de> Deserialize<'de> for Language[src]

impl PartialEq<Language> for Language[src]

impl Serialize for Language[src]

impl StructuralPartialEq for Language[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

impl<T> From<T> for T[src]

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

impl<T> Pointable for T

type Init = T

The type for initializers.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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

type Error = Infallible

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.