From fd98a3590f87928f02e9426d39cc51cdcccac945 Mon Sep 17 00:00:00 2001 From: Aleksey Yakovlev Date: Wed, 26 Jun 2024 16:09:42 +0700 Subject: [PATCH] removed StringCompilerSource --- src/compiler/compiler_source.rs | 24 ------------------------ src/main.rs | 6 +++--- 2 files changed, 3 insertions(+), 27 deletions(-) diff --git a/src/compiler/compiler_source.rs b/src/compiler/compiler_source.rs index c363d3f..5883be4 100644 --- a/src/compiler/compiler_source.rs +++ b/src/compiler/compiler_source.rs @@ -8,30 +8,6 @@ pub(crate) trait CompilerSource { fn path(&self) -> PathBuf; } -pub(crate) struct StringCompilerSource { - content: String, - path: PathBuf, -} - -impl StringCompilerSource { - pub(crate) fn new(path: PathBuf, text: &str) -> StringCompilerSource { - StringCompilerSource { - content: text.to_string(), - path, - } - } -} - -impl CompilerSource for StringCompilerSource { - fn read(&self) -> Result { - Ok(self.content.clone()) - } - - fn path(&self) -> PathBuf { - self.path.clone() - } -} - pub(crate) struct FileCompilerSource { path: PathBuf, } diff --git a/src/main.rs b/src/main.rs index 6983312..2094b85 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ use std::env::temp_dir; use std::fs::File; use std::io::Read; use std::path::PathBuf; -use crate::cli::{run_build, run_cli}; +use crate::cli::{Error, run_build, run_cli}; mod cli; mod compiler; @@ -12,8 +12,8 @@ fn main() { } #[test] -fn run_sample() { - run_build("sample.hexo".to_string(), None).unwrap(); +fn run_sample() -> Result<(), Error> { + run_build("sample.hexo".to_string(), None) } // list files in directory test cases