@@ -94,7 +94,7 @@ use std::{
9494 time:: SystemTime ,
9595} ;
9696
97- use toml_edit:: { Document , Item , Table , TomlError } ;
97+ use toml_edit:: { DocumentMut , Item , Table , TomlError } ;
9898
9999/// Error type used by this crate.
100100pub enum Error {
@@ -302,7 +302,7 @@ fn read_cargo_toml(
302302/// Returns a hash map that maps from dep name to the package name. Dep name
303303/// and package name can be the same if there doesn't exist any rename.
304304fn extract_workspace_dependencies (
305- workspace_toml : & Document ,
305+ workspace_toml : & DocumentMut ,
306306) -> Result < BTreeMap < String , String > , Error > {
307307 Ok ( workspace_dep_tables ( & workspace_toml)
308308 . into_iter ( )
@@ -316,7 +316,7 @@ fn extract_workspace_dependencies(
316316}
317317
318318/// Return an iterator over all `[workspace.dependencies]`
319- fn workspace_dep_tables ( cargo_toml : & Document ) -> Option < & Table > {
319+ fn workspace_dep_tables ( cargo_toml : & DocumentMut ) -> Option < & Table > {
320320 cargo_toml
321321 . get ( "workspace" )
322322 . and_then ( |w| w. as_table ( ) ?. get ( "dependencies" ) ?. as_table ( ) )
@@ -328,16 +328,16 @@ fn sanitize_crate_name<S: AsRef<str>>(name: S) -> String {
328328}
329329
330330/// Open the given `Cargo.toml` and parse it into a hashmap.
331- fn open_cargo_toml ( path : & Path ) -> Result < Document , Error > {
331+ fn open_cargo_toml ( path : & Path ) -> Result < DocumentMut , Error > {
332332 let content = fs:: read_to_string ( path)
333333 . map_err ( |e| Error :: CouldNotRead { source : e, path : path. into ( ) } ) ?;
334- content. parse :: < Document > ( ) . map_err ( |e| Error :: InvalidToml { source : e } )
334+ content. parse :: < DocumentMut > ( ) . map_err ( |e| Error :: InvalidToml { source : e } )
335335}
336336
337337/// Extract all crate names from the given `Cargo.toml` by checking the `dependencies` and
338338/// `dev-dependencies`.
339339fn extract_crate_names (
340- cargo_toml : & Document ,
340+ cargo_toml : & DocumentMut ,
341341 workspace_dependencies : BTreeMap < String , String > ,
342342) -> Result < CrateNames , Error > {
343343 let package_name = extract_package_name ( cargo_toml) ;
@@ -377,11 +377,11 @@ fn extract_crate_names(
377377 Ok ( root_pkg. into_iter ( ) . chain ( dep_pkgs) . collect ( ) )
378378}
379379
380- fn extract_package_name ( cargo_toml : & Document ) -> Option < & str > {
380+ fn extract_package_name ( cargo_toml : & DocumentMut ) -> Option < & str > {
381381 cargo_toml. get ( "package" ) ?. get ( "name" ) ?. as_str ( )
382382}
383383
384- fn target_dep_tables ( cargo_toml : & Document ) -> impl Iterator < Item = & Table > {
384+ fn target_dep_tables ( cargo_toml : & DocumentMut ) -> impl Iterator < Item = & Table > {
385385 cargo_toml. get ( "target" ) . into_iter ( ) . filter_map ( Item :: as_table) . flat_map ( |t| {
386386 t. iter ( ) . map ( |( _, value) | value) . filter_map ( Item :: as_table) . flat_map ( dep_tables)
387387 } )
@@ -408,9 +408,9 @@ mod tests {
408408 ) => {
409409 #[ test]
410410 fn $name( ) {
411- let cargo_toml = $cargo_toml. parse:: <Document >( )
411+ let cargo_toml = $cargo_toml. parse:: <DocumentMut >( )
412412 . expect( "Parses `Cargo.toml`" ) ;
413- let workspace_cargo_toml = $workspace_toml. parse:: <Document >( )
413+ let workspace_cargo_toml = $workspace_toml. parse:: <DocumentMut >( )
414414 . expect( "Parses workspace `Cargo.toml`" ) ;
415415
416416 let workspace_deps = extract_workspace_dependencies( & workspace_cargo_toml)
0 commit comments