ryo_mutations/basic/
visibility.rs1use ryo_source::pure::PureVis;
4use ryo_symbol::SymbolId;
5
6use crate::Mutation;
7
8#[derive(Debug, Clone)]
14pub struct ChangeVisibilityMutation {
15 pub symbol_id: SymbolId,
17 pub to: PureVis,
19}
20
21impl ChangeVisibilityMutation {
22 pub fn new(symbol_id: SymbolId, to: PureVis) -> Self {
23 Self { symbol_id, to }
24 }
25
26 pub fn to_public(symbol_id: SymbolId) -> Self {
27 Self::new(symbol_id, PureVis::Public)
28 }
29
30 pub fn to_private(symbol_id: SymbolId) -> Self {
31 Self::new(symbol_id, PureVis::Private)
32 }
33
34 pub fn to_crate(symbol_id: SymbolId) -> Self {
35 Self::new(symbol_id, PureVis::Crate)
36 }
37}
38
39impl Mutation for ChangeVisibilityMutation {
40 fn describe(&self) -> String {
41 format!(
42 "Change visibility of SymbolId({:?}) to {:?}",
43 self.symbol_id, self.to
44 )
45 }
46
47 fn mutation_type(&self) -> &'static str {
48 "ChangeVisibility"
49 }
50
51 fn box_clone(&self) -> Box<dyn Mutation> {
52 Box::new(self.clone())
53 }
54}