mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-16 09:15:02 +01:00
things
This commit is contained in:
parent
a9e488f3e3
commit
0f05ef625a
11 changed files with 153 additions and 70 deletions
|
|
@ -1,16 +1,16 @@
|
|||
use syn::{parse_quote, visit_mut::VisitMut, Visibility};
|
||||
|
||||
use crate::processor::{ProcessChecker, Processor};
|
||||
use crate::processor::{ProcessChecker, Processor, ProcessState};
|
||||
|
||||
struct Visitor {
|
||||
pub_crate: Visibility,
|
||||
has_made_change: bool,
|
||||
process_state: ProcessState,
|
||||
}
|
||||
|
||||
impl Visitor {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
has_made_change: false,
|
||||
process_state: ProcessState::NoChange,
|
||||
pub_crate: parse_quote! { pub(crate) },
|
||||
}
|
||||
}
|
||||
|
|
@ -19,7 +19,7 @@ impl Visitor {
|
|||
impl VisitMut for Visitor {
|
||||
fn visit_visibility_mut(&mut self, vis: &mut Visibility) {
|
||||
if let Visibility::Public(_) = vis {
|
||||
self.has_made_change = true;
|
||||
self.process_state = ProcessState::Changed;
|
||||
*vis = self.pub_crate.clone();
|
||||
}
|
||||
}
|
||||
|
|
@ -29,10 +29,10 @@ impl VisitMut for Visitor {
|
|||
pub struct Privatize {}
|
||||
|
||||
impl Processor for Privatize {
|
||||
fn process_file(&mut self, krate: &mut syn::File, _: &mut ProcessChecker) -> bool {
|
||||
fn process_file(&mut self, krate: &mut syn::File, _: &mut ProcessChecker) -> ProcessState {
|
||||
let mut visitor = Visitor::new();
|
||||
visitor.visit_file_mut(krate);
|
||||
visitor.has_made_change
|
||||
visitor.process_state
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue