diff --git a/core/src/source_map.rs b/core/src/source_map.rs index 1aa453a..4549b01 100644 --- a/core/src/source_map.rs +++ b/core/src/source_map.rs @@ -24,20 +24,23 @@ pub struct SourceMap { impl SourceMap { pub fn new( mappings: &str, - file: Option, - names: Vec, - sources_content: Vec>, - source_root: Option, - sources: Vec>, + file: Option<&str>, + names: Vec<&str>, + sources_content: Vec>, + source_root: Option<&str>, + sources: Vec>, ) -> Self { Self { version: VERSION, mappings: String::from(mappings), - file, - names, - sources_content, - source_root, - sources, + file: file.map(|f| f.to_owned()), + names: names.iter().map(|&n| n.to_owned()).collect::>(), + sources_content: sources_content + .iter() + .map(|s| s.map(|s| s.to_owned())) + .collect(), + source_root: source_root.map(|s| s.to_owned()), + sources: sources.iter().map(|s| s.map(|s| s.to_owned())).collect(), } }