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: usizeImplementationsยง
Sourceยงimpl CountRoo
impl CountRoo
pub fn count_lines_of_code(&mut self) -> Result<usize, LocCounterError>
pub fn count_lines_for_file( count_empty_lines: bool, entry: &String, ) -> Result<usize, LocCounterError>
Sourcepub fn calculate_extension_counts(&self) -> HashMap<String, usize>
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
configmember of the struct holds relevant configuration data. config.count_empty_linesinfluences the counting behavior (Toggling it to true marks whitespace new lines as code lines).config.project_src_pathdefines the base directory for searching files (Usually src folder).
pub fn calculate_extension_counts_for( count_empty_lines: bool, path: &String, ) -> HashMap<String, usize>
pub fn with_config_builder( config_builder: ConfigBuilder, ) -> Result<Self, LocCounterError>
Trait Implementationsยง
Sourceยงimpl AllTypesCounter for CountRoo
Available on crate feature default only.
impl AllTypesCounter for CountRoo
Available on crate feature
default only.fn count_lines_of_code_for_all_types( &mut self, ) -> Result<usize, LocCounterError>
Sourceยงimpl Analyzable for CountRoo
impl Analyzable for CountRoo
fn get_project_base(&self) -> String
fn is_code_file(&self, path: &str) -> bool
fn get_manifest(&self) -> Result<Manifest, LocCounterError>
fn count_code_files(&self, project_path: &str) -> Result<usize, LocCounterError>
fn count_crates(&self) -> Result<usize, LocCounterError>
fn get_project_name(&self) -> Result<Option<String>, LocCounterError>
fn get_rust_version() -> Option<String>
fn get_rust_edition(&self) -> Option<String>
fn count_rust_modules(project_path: &str) -> Result<usize, LocCounterError>
fn analyze_code_base(&mut self)
Sourceยงimpl CertainTypesCounter for CountRoo
Available on crate feature default only.
impl CertainTypesCounter for CountRoo
Available on crate feature
default only.fn count_lines_of_code_for_certain_types( &mut self, ) -> Result<usize, LocCounterError>
Auto Trait Implementationsยง
impl Freeze for CountRoo
impl RefUnwindSafe for CountRoo
impl Send for CountRoo
impl Sync for CountRoo
impl Unpin for CountRoo
impl UnwindSafe for CountRoo
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> Instrument for T
impl<T> Instrument for T
Sourceยงfn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Sourceยงfn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSourceยงimpl<T> Pointable for T
impl<T> Pointable for T
Sourceยงimpl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Sourceยงfn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more