Skip to content

chore: internal code tidy - #211

Merged
tisonkun merged 1 commit into
mainfrom
tidytidy
Jun 6, 2026
Merged

chore: internal code tidy#211
tisonkun merged 1 commit into
mainfrom
tidytidy

Conversation

@tisonkun

@tisonkun tisonkun commented Jun 6, 2026

Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: tison <wander4096@gmail.com>
Comment thread fmt/src/document/mod.rs
Comment on lines +168 to 178
pub fn save(&mut self) -> Result<(), Error> {
let filepath = self.filepath.as_path();
fs::write(filepath, self.parser.file_content.content())
.or_raise(|| Error::new(format!("cannot save document {}", filepath.display())))
}

pub fn save_to(&mut self, filepath: impl AsRef<Path>) -> Result<(), Error> {
let filepath = filepath.as_ref();
fs::write(filepath, self.parser.file_content.content())
.or_raise(|| Error::new(format!("cannot save document {}", filepath.display())))
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually we don't need &mut self but &self here. But use &mut for write operation is fine and it's good to distinguish save/save_to.

@tisonkun
tisonkun enabled auto-merge (squash) June 6, 2026 16:14
@tisonkun
tisonkun merged commit 113f771 into main Jun 6, 2026
17 checks passed
@tisonkun
tisonkun deleted the tidytidy branch June 6, 2026 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant