Struct countroo::CountRoo

source ยท
pub struct CountRoo {
    pub config: Config,
    pub total_lines: usize,
    pub num_files: usize,
    pub num_crates: usize,
    pub project_name: Option<String>,
    pub rust_edition: Option<String>,
    pub rustc_version: Option<String>,
    pub num_modules: usize,
}
Expand description

CountRoo ๐Ÿฆ˜ - Your Rust Projectโ€™s Best Mate for Code Insights!

Embark on an adventure through your codebase with CountRoo, the struct that leaps across your files, counting lines of code, tracking crates, and more, all while keeping it fun! ๐ŸŽ‰

ยงFeatures

  • Total Lines of Code ๐Ÿ“Š: Keeps track of the total lines across your project.
  • Number of Files ๐Ÿ—‚๏ธ: Counts the files explored in the code safari.
  • Crate Count ๐Ÿ“ฆ: Tallies up the crates your project depends on.
  • Project Name ๐Ÿท๏ธ: Captures the name of your project, if available.
  • Rust Edition ๐Ÿฆ€: Identifies the Rust edition your project is using.
  • Rust Compiler Version ๐Ÿ”ง: Determines the version of the Rust compiler (rustc) in use.
  • Module Count ๐Ÿ“š: Counts the number of modules within your Rust project.

ยงExample

use countroo::prelude::*;
let config = Config::from_rel_file_path("path/to/config").unwrap();
let mut countroo = CountRoo::default();
let total_lines = countroo.count_lines_of_code().unwrap();
println!("Total lines of code: {}", total_lines);///

// Or you could just use macros for convenience such as count_some!() or count_it_all!()

Dive in and let CountRoo uncover the hidden gems and forgotten fossils in your codebase. Happy counting! ๐Ÿš€

Fieldsยง

ยงconfig: Configยงtotal_lines: usizeยงnum_files: usizeยงnum_crates: usizeยงproject_name: Option<String>ยงrust_edition: Option<String>ยงrustc_version: Option<String>ยงnum_modules: usize

Implementationsยง

sourceยง

impl CountRoo

source

pub fn count_lines_of_code(&mut self) -> Result<usize, LocCounterError>

source

pub fn count_lines_for_file( count_empty_lines: bool, entry: &String ) -> Result<usize, LocCounterError>

source

pub fn calculate_extension_counts(&self) -> HashMap<String, usize>

Calculates and aggregates the lines of code per occurrences of each file extension within the projectโ€™s source directory.

ยงArguments
  • self: A reference to the current instance of the struct.
ยงReturns

A HashMap where:

  • Keys are strings representing unique file extensions found.
  • Values are the corresponding counts of files with that extension.
ยงAssumptions
  • The config member of the struct holds relevant configuration data.
  • config.count_empty_lines influences the counting behavior (Toggling it to true marks whitespace new lines as code lines).
  • config.project_src_path defines the base directory for searching files (Usually src folder).
source

pub fn calculate_extension_counts_for( count_empty_lines: bool, path: &String ) -> HashMap<String, usize>

source

pub fn with_config_builder( config_builder: ConfigBuilder ) -> Result<Self, LocCounterError>

Trait Implementationsยง

sourceยง

impl AllTypesCounter for CountRoo

sourceยง

impl Analyzable for CountRoo

sourceยง

impl CertainTypesCounter for CountRoo

sourceยง

impl Debug for CountRoo

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

impl Default for CountRoo

sourceยง

fn default() -> Self

Returns the โ€œdefault valueโ€ for a type. Read more
sourceยง

impl Display for CountRoo

sourceยง

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

Formats the value using the given formatter. Read more
sourceยง

impl Exportable for CountRoo

sourceยง

fn export(&self, writer: Box<dyn OutputWriter>) -> Result<(), Error>

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> From<T> for T

sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

ยง

impl<T> Instrument for T

ยง

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
ยง

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

ยง

impl<T> Pointable for T

ยง

const ALIGN: usize = _

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
ยง

impl<T> ToCompactString for T
where T: Display,

ยง

fn to_compact_string(&self) -> CompactString

Converts the given value to a [CompactString]. Read more
sourceยง

impl<T> ToString for T
where 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 T
where 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 T
where 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.
ยง

impl<T> WithSubscriber for T

ยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
ยง

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more