mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-11 05:34:11 +03:00
static-site-gen: get rid of Result
This commit is contained in:
parent
65a18591e5
commit
bbc8c36d30
@ -1,9 +1,9 @@
|
||||
platform "static-site-gen"
|
||||
requires {} { transformFileContent : Str -> Result Str Str }
|
||||
requires {} { transformFileContent : Str -> Str }
|
||||
exposes []
|
||||
packages {}
|
||||
imports []
|
||||
provides [transformFileContentForHost]
|
||||
|
||||
transformFileContentForHost : Str -> Result Str Str
|
||||
transformFileContentForHost : Str -> Str
|
||||
transformFileContentForHost = \list -> transformFileContent list
|
||||
|
@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
extern "C" {
|
||||
#[link_name = "roc__transformFileContentForHost_1_exposed"]
|
||||
fn roc_transformFileContentForHost(content: RocStr) -> RocResult<RocStr, RocStr>;
|
||||
fn roc_transformFileContentForHost(content: RocStr) -> RocStr;
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@ -126,9 +126,8 @@ fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Resul
|
||||
})?;
|
||||
|
||||
let roc_content = RocStr::from(rust_content.as_str());
|
||||
let roc_result = unsafe { roc_transformFileContentForHost(roc_content) };
|
||||
match Result::from(roc_result) {
|
||||
Ok(roc_output_str) => {
|
||||
let roc_output_str = unsafe { roc_transformFileContentForHost(roc_content) };
|
||||
|
||||
let input_relpath = input_file
|
||||
.strip_prefix(input_dir)
|
||||
.map_err(|e| e.to_string())?
|
||||
@ -148,13 +147,6 @@ fn process_file(input_dir: &Path, output_dir: &Path, input_file: &Path) -> Resul
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
Err(roc_error_str) => Err(format!(
|
||||
"Error transforming {}: {}",
|
||||
input_file.to_str().unwrap_or("an input file"),
|
||||
roc_error_str.as_str()
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
fn find_files(dir: &Path, file_paths: &mut Vec<PathBuf>) -> std::io::Result<()> {
|
||||
for entry in fs::read_dir(dir)? {
|
||||
|
@ -3,12 +3,11 @@ app "static-site"
|
||||
imports [pf.Html.{ html, head, body, div, text }]
|
||||
provides [transformFileContent] to pf
|
||||
|
||||
transformFileContent : Str -> Result Str Str
|
||||
transformFileContent : Str -> Str
|
||||
transformFileContent = \content ->
|
||||
content
|
||||
|> view
|
||||
|> Html.render
|
||||
|> Ok
|
||||
|
||||
view : Str -> Html.Node
|
||||
view = \content ->
|
||||
|
Loading…
Reference in New Issue
Block a user