Struct UseBuilder

Source
pub struct UseBuilder { /* private fields */ }
Expand description

The struct to represent the builder for proc_use.

Implementations§

Source§

impl UseBuilder

Source

pub fn new() -> Self

Returns a UserBuilder with no mod or use statemetns and unused defaulted to true.

Source

pub fn mod_file(&mut self, file: PathBuf) -> &mut Self

Adds a file to mod to the builder.

§Arguments
  • file - A PathBuf to the file that needs to be modded.
Source

pub fn use_file(&mut self, file: PathBuf, use_stmt: String) -> &mut Self

Adds a file to use to the builder, and use pattern.

§Arguments
  • file - A PathBuf to the file that needs to be modded.
  • use_stmt - A String that holds the use pattern for the file.
Source

pub fn mod_file_alias(&mut self, file: PathBuf, alias: &str) -> &mut Self

Adds a file to use to the builder. Uses an alias on mod statement.

§Arguments
  • file - A PathBuf to the file that needs to be modded.
  • alias - Alternate name for imported mod. Eg import foo.rs as mod bar.
Source

pub fn use_file_alias( &mut self, file: PathBuf, use_stmt: String, alias: &str, ) -> &mut Self

Adds a file to use to the builder, and use pattern. Uses an alias on mod statement.

§Arguments
  • file - A PathBuf to the file that needs to be modded.
  • use_stmt - A String that holds the use pattern for the file.
  • alias - Alternate name for imported mod. Eg import foo.rs as mod bar.
Source

pub fn use_crate(&mut self, use_stmt: String) -> &mut Self

Adds a crate to use to the builder with a use pattern.

§Arguments
  • use_stmt - A String that holds the use pattern for the crate.
Source

pub fn mod_glob(&mut self, globstring: &str) -> &mut Self

Glob a file path for files to mod.

§Arguments
  • globstring - The glob pattern string to match.
§Example
let builder = UseBuilder::new()
        .mod_glob("src/util/*.rs");
Source

pub fn use_glob(&mut self, globstring: &str, use_stmt: String) -> &mut Self

Glob a file path for files to use.

§Arguments
  • globstring - The glob pattern string to match.
§Example
let builder = UseBuilder::new()
        .use_glob("src/util/*.rs", "*".into());
Source

pub fn mod_glob_alias(&mut self, globstring: &str, alias: &str) -> &mut Self

Glob a file path for files to mod. Uses an alias on mod statement.

§Arguments
  • globstring - The glob pattern string to match.
§Example
let builder = UseBuilder::new()
        .mod_glob("src/util/*.rs");
  • alias - Alternate name for imported mod. Eg import foo.rs as mod bar.
Source

pub fn use_glob_alias( &mut self, globstring: &str, use_stmt: String, alias: &str, ) -> &mut Self

Glob a file path for files to use. Uses an alias on mod statement.

§Arguments
  • globstring - The glob pattern string to match.
§Example
let builder = UseBuilder::new()
        .use_glob("src/util/*.rs", "*".into());
  • alias - Alternate name for imported mod. Eg import foo.rs as mod bar.
Source

pub fn allow_unused(&mut self) -> &mut Self

Disables the unused import error for each import.

Source

pub fn warn_unused(&mut self) -> &mut Self

Enables the unused import error for each import.

Source

pub fn write_to_file_use(&mut self, path: PathBuf) -> &mut Self

Writes the use statements to a file.

§Arguments
  • path - A PathBuf to the file that is to be written.
Source

pub fn write_to_file_mod(&mut self, path: PathBuf) -> &mut Self

Writes the mod statements to a file.

§Arguments
  • path - A PathBuf to the file that is to be written.
Source

pub fn write_to_file_all(&mut self, path: PathBuf) -> &mut Self

Writes the mod and use statements to a file.

§Arguments
  • path - A PathBuf to the file that is to be written.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.