This repository has been archived on 2024-10-16. You can view files and clone it, but cannot push or open issues or pull requests.
2023-07-08 14:43:11 +02:00
|
|
|
//! # common functionalities
|
|
|
|
//!
|
2023-09-20 20:35:07 +02:00
|
|
|
//! This crate is part of [`pt`](../libpt/index.html), but can also be used as a standalone
|
|
|
|
//! module.
|
|
|
|
//!
|
|
|
|
//! This crate implements core functionality useful for many use cases, such as macros,
|
|
|
|
//! formatting functions and more.
|
2023-07-08 14:43:11 +02:00
|
|
|
|
2023-07-09 17:53:20 +02:00
|
|
|
/// macros to make things faster in your code
|
2023-07-08 14:43:11 +02:00
|
|
|
pub mod macros;
|
2024-08-30 17:39:10 +02:00
|
|
|
|
|
|
|
/// ## Get the name of the crate that uses your library
|
|
|
|
///
|
|
|
|
/// Let's say you're writing the library `foo` and need the name of the crate that uses `foo`. With
|
|
|
|
/// this function, you can get the name of the crate that uses `foo`.
|
|
|
|
///
|
|
|
|
/// Will return [None] if [`std::env::current_exe()`] errors or if conversion to [String] from [std::ffi::OsStr] fails.
|
|
|
|
pub fn get_crate_name() -> Option<String> {
|
|
|
|
if let Ok(exe) = std::env::current_exe() {
|
|
|
|
return Some(exe.file_stem()?.to_str()?.to_string());
|
|
|
|
}
|
|
|
|
None
|
|
|
|
}
|