1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/// Defines an import (`use` statement).
#[allow(dead_code)]
#[derive(Debug, Clone)]
pub struct Import {
    /// The contents of the import.
    line: String,
    /// Import visibility.
    pub vis: Option<String>,
}

impl Import {
    /// Returns a new import.
    /// 
    /// * `path` - The path to the base import.
    /// * `ty` - The type to import.
    /// 
    /// # Examples
    /// 
    /// ```
    /// use rust_codegen::Import;
    /// 
    /// let rust_codegen_fn_import = Import::new("rust_codegen", "Function");
    /// ```
    pub fn new(path: &str, ty: &str) -> Self {
        Import {
            line: format!("{}::{}", path, ty),
            vis: None,
        }
    }

    /// Set the import visibility.
    /// 
    /// # Arguments
    /// 
    /// * `vis` - The visibility of the import.
    /// 
    /// # Examples
    /// 
    /// ```
    /// use rust_codegen::Import;
    /// 
    /// let mut rust_codegen_fn_import = Import::new("rust_codegen", "Function");
    /// rust_codegen_fn_import.vis("pub");
    pub fn vis(&mut self, vis: &str) -> &mut Self {
        self.vis = Some(vis.to_string());
        self
    }
}