Crates.io | crate-paths-cli |
lib.rs | crate-paths-cli |
version | 0.1.1 |
created_at | 2025-06-27 15:23:30.043498+00 |
updated_at | 2025-06-27 16:57:22.235822+00 |
description | Cli that builds a tree of a crate's item paths |
homepage | |
repository | https://github.com/stayhydated/crate-paths |
max_upload_size | |
id | 1728840 |
size | 70,462 |
tired of doing "something" like this?
let struct_name = get();
let field_name = get();
let field_type = get();
let tokens = quote! {
#[derive(Clone, serde::Serialize, serde::Deserialize)]
pub struct #struct_name {
#field_name: std::sync::Arc<std::sync::RwLock<std::collections::HashMap<String, #field_type>>>,
metrics: std::sync::Arc<std::sync::atomic::AtomicU64>,
}
impl #struct_name {
pub fn new() -> Self {
Self {
#field_name: std::sync::Arc::new(std::sync::RwLock::new(std::collections::HashMap::new())),
metrics: std::sync::Arc::new(std::sync::atomic::AtomicU64::new(0)),
}
}
}
};
This cli will generate definitions that will allow you to do:
let struct_name = get();
let field_name = get();
let field_type = get();
use serde_crate_paths::{Serialize, Deserialize};
use std_crate_paths::sync::{Arc, RwLock};
use std_crate_paths::sync::atomic::AtomicU64;
use std_crate_paths::collections::HashMap;
let tokens = quote! {
#[derive(Clone, #Serialize, #Deserialize)]
pub struct #struct_name {
#field_name: #Arc<#RwLock<#HashMap<String, #field_type>>>,
metrics: #Arc<#AtomicU64>,
}
impl #struct_name {
pub fn new() -> Self {
Self {
#field_name: #Arc::new(#RwLock::new(#HashMap::new())),
metrics: #Arc::new(#AtomicU64::new(0)),
}
}
}
};
See a basic example in example, whose Justfile contains information about the backend used.