summaryrefslogtreecommitdiff
path: root/core/extensions.rs
diff options
context:
space:
mode:
Diffstat (limited to 'core/extensions.rs')
-rw-r--r--core/extensions.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/extensions.rs b/core/extensions.rs
index 2a578429b..94c4a2a79 100644
--- a/core/extensions.rs
+++ b/core/extensions.rs
@@ -1,4 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use crate::modules::ModuleCode;
use crate::OpState;
use anyhow::Context as _;
use anyhow::Error;
@@ -23,13 +24,12 @@ pub enum ExtensionFileSourceCode {
}
impl ExtensionFileSourceCode {
- pub fn load(&self) -> Result<String, Error> {
+ pub fn load(&self) -> Result<ModuleCode, Error> {
match self {
- ExtensionFileSourceCode::IncludedInBinary(code) => Ok(code.to_string()),
+ ExtensionFileSourceCode::IncludedInBinary(code) => Ok((*code).into()),
ExtensionFileSourceCode::LoadedFromFsDuringSnapshot(path) => {
- let msg = format!("Failed to read \"{}\"", path.display());
- let code = std::fs::read_to_string(path).context(msg)?;
- Ok(code)
+ let msg = || format!("Failed to read \"{}\"", path.display());
+ Ok(std::fs::read_to_string(path).with_context(msg)?.into())
}
}
}