Skip to main content

NargoFormatter

Struct NargoFormatter 

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

格式化 Nargo 相关文件的工具

支持格式化 Nargo、TS、TSX、JS、JSX 文件,能够处理 Nargo 单文件组件的不同区块。

Implementations§

Source§

impl NargoFormatter

Source

pub fn new() -> Self

创建新的格式化器实例,使用默认配置

§返回值

格式化器实例

Source

pub fn with_config(config: FormatterConfig) -> Self

创建新的格式化器实例,使用自定义配置

§参数
  • config: 格式化配置
§返回值

格式化器实例

Source

pub fn load_config_from_file(file_path: &str) -> Result<FormatterConfig>

从文件加载配置

§参数
  • file_path: 配置文件路径
§返回值

配置实例

Source

pub fn save_config_to_file( config: &FormatterConfig, file_path: &str, ) -> Result<()>

保存配置到文件

§参数
  • config: 配置实例
  • file_path: 配置文件路径
§返回值

操作结果

Source

pub async fn format(&self, source: &str) -> Result<String>

格式化源代码

§参数
  • source: 源代码字符串
§返回值

格式化后的代码

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, 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V