Skip to content

Commit

Permalink
removed path buf argument
Browse files Browse the repository at this point in the history
  • Loading branch information
lexa-diky committed Jul 10, 2024
1 parent c495244 commit 1fcd0a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs::File;
use std::io::Write;
use std::panic::catch_unwind;
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::thread::sleep;
use std::time::{Duration, Instant};

Expand Down Expand Up @@ -127,7 +127,8 @@ impl Cli {
let context = HexoCompilerContext::new();
let compiler = HexoCompiler::new(context);

let compiler_source = FileCompilerSource::new(PathBuf::from(source.clone()));
let source_path = Path::new(&source);
let compiler_source = FileCompilerSource::new(&source_path);

let compilation_result = compiler
.compile(&compiler_source)
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/compiler_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ pub(crate) struct FileCompilerSource {
}

impl FileCompilerSource {
pub(crate) fn new(path: PathBuf) -> FileCompilerSource {
FileCompilerSource { path }
pub(crate) fn new(path: &Path) -> FileCompilerSource {
FileCompilerSource { path: path.to_path_buf() }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/rst/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl RstCompiler<'_> {
let bb = self.build_bytes(context_id, &mut context, cst.main().emits())?;

Ok(HexoFile::new(
cst.path().to_path_buf(),
cst.path(),
context,
bb,
))
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/rst/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ pub(crate) struct HexoFile {

impl HexoFile {

pub(crate) fn new(path: PathBuf, context: CompilationContext, emits: ByteBuffer) -> HexoFile {
pub(crate) fn new(path: &Path, context: CompilationContext, emits: ByteBuffer) -> HexoFile {
HexoFile {
path,
path: path.to_path_buf(),
context,
emits,
}
Expand Down

0 comments on commit 1fcd0a8

Please sign in to comment.