@@ -39,8 +39,8 @@ use crate::{
3939/// "Hello World\nconsole.log('test');\nconsole.log('test2');\nHello2\n"
4040/// );
4141/// assert_eq!(
42- /// source.map(&MapOptions::new(false)).unwrap(),
43- /// SourceMap::from_json(
42+ /// source.map(&MapOptions::new(false)).unwrap().as_ref() ,
43+ /// & SourceMap::from_json(
4444/// r#"{
4545/// "version": 3,
4646/// "mappings": ";AAAA;AACA;ACDA",
@@ -156,8 +156,8 @@ impl Source for ConcatSource {
156156 self . children ( ) . iter ( ) . map ( |child| child. size ( ) ) . sum ( )
157157 }
158158
159- fn map ( & self , options : & MapOptions ) -> Option < SourceMap > {
160- get_map ( self , options)
159+ fn map < ' a > ( & ' a self , options : & MapOptions ) -> Option < Cow < ' a , SourceMap < ' a > > > {
160+ get_map ( self , options) . map ( Cow :: Owned )
161161 }
162162
163163 fn to_writer ( & self , writer : & mut dyn std:: io:: Write ) -> std:: io:: Result < ( ) > {
@@ -376,8 +376,8 @@ mod tests {
376376 assert_eq ! ( source. size( ) , 62 ) ;
377377 assert_eq ! ( source. source( ) , expected_source) ;
378378 assert_eq ! (
379- source. map( & MapOptions :: new( false ) ) . unwrap( ) ,
380- SourceMap :: from_json(
379+ source. map( & MapOptions :: new( false ) ) . unwrap( ) . as_ref ( ) ,
380+ & SourceMap :: from_json(
381381 r#"{
382382 "version": 3,
383383 "mappings": ";AAAA;AACA;ACDA",
@@ -392,8 +392,8 @@ mod tests {
392392 . unwrap( )
393393 ) ;
394394 assert_eq ! (
395- source. map( & MapOptions :: default ( ) ) . unwrap( ) ,
396- SourceMap :: from_json(
395+ source. map( & MapOptions :: default ( ) ) . unwrap( ) . as_ref ( ) ,
396+ & SourceMap :: from_json(
397397 r#"{
398398 "version": 3,
399399 "mappings": ";AAAA;AACA;ACDA",
@@ -426,8 +426,8 @@ mod tests {
426426 assert_eq ! ( source. size( ) , 62 ) ;
427427 assert_eq ! ( source. source( ) , expected_source) ;
428428 assert_eq ! (
429- source. map( & MapOptions :: new( false ) ) . unwrap( ) ,
430- SourceMap :: from_json(
429+ source. map( & MapOptions :: new( false ) ) . unwrap( ) . as_ref ( ) ,
430+ & SourceMap :: from_json(
431431 r#"{
432432 "version": 3,
433433 "mappings": ";AAAA;AACA;ACDA",
@@ -442,8 +442,8 @@ mod tests {
442442 . unwrap( )
443443 ) ;
444444 assert_eq ! (
445- source. map( & MapOptions :: default ( ) ) . unwrap( ) ,
446- SourceMap :: from_json(
445+ source. map( & MapOptions :: default ( ) ) . unwrap( ) . as_ref ( ) ,
446+ & SourceMap :: from_json(
447447 r#"{
448448 "version": 3,
449449 "mappings": ";AAAA;AACA;ACDA",
@@ -476,8 +476,8 @@ mod tests {
476476 assert_eq ! ( source. size( ) , 62 ) ;
477477 assert_eq ! ( source. source( ) , expected_source) ;
478478 assert_eq ! (
479- source. map( & MapOptions :: new( false ) ) . unwrap( ) ,
480- SourceMap :: from_json(
479+ source. map( & MapOptions :: new( false ) ) . unwrap( ) . as_ref ( ) ,
480+ & SourceMap :: from_json(
481481 r#"{
482482 "version": 3,
483483 "mappings": ";AAAA;AACA;ACDA",
@@ -492,8 +492,8 @@ mod tests {
492492 . unwrap( )
493493 ) ;
494494 assert_eq ! (
495- source. map( & MapOptions :: default ( ) ) . unwrap( ) ,
496- SourceMap :: from_json(
495+ source. map( & MapOptions :: default ( ) ) . unwrap( ) . as_ref ( ) ,
496+ & SourceMap :: from_json(
497497 r#"{
498498 "version": 3,
499499 "mappings": ";AAAA;AACA;ACDA",
@@ -542,7 +542,7 @@ mod tests {
542542 assert_eq ! ( source. buffer( ) , expected_source. as_bytes( ) ) ;
543543
544544 let map = source. map ( & MapOptions :: new ( false ) ) . unwrap ( ) ;
545- assert_eq ! ( map, expected_map1) ;
545+ assert_eq ! ( map. as_ref ( ) , & expected_map1) ;
546546
547547 // TODO: test hash
548548 }
@@ -578,8 +578,8 @@ mod tests {
578578 ] ) ;
579579
580580 assert_eq ! (
581- source. map( & MapOptions :: default ( ) ) . unwrap( ) ,
582- SourceMap :: from_json(
581+ source. map( & MapOptions :: default ( ) ) . unwrap( ) . as_ref ( ) ,
582+ & SourceMap :: from_json(
583583 r#"{
584584 "mappings": "AAAA,K,CCAA,M;ADAA;;ACAA",
585585 "names": [],
0 commit comments