fn walk_self_maps(visitor: &mut dyn FnMut(usize, usize, String, String) -> bool) {
    let re = Regex::new(r"^(?P<start>[0-9a-f]{8,16})-(?P<end>[0-9a-f]{8,16}) (?P<perm>[-rwxp]{4}) (?P<offset>[0-9a-f]{8}) [0-9a-f]+:[0-9a-f]+ [0-9]+\s+(?P<path>.*)$")
        .unwrap();

    let mapsfile = File::open("/proc/self/maps").expect("Unable to open /proc/self/maps");

    for line in BufReader::new(mapsfile).lines() {
        let line = line.unwrap();
        if let Some(caps) = re.captures(&line) {
            if visitor(
                usize::from_str_radix(caps.name("start").unwrap().as_str(), 16).unwrap(),
                usize::from_str_radix(caps.name("end").unwrap().as_str(), 16).unwrap(),
                caps.name("perm").unwrap().as_str().to_string(),
                caps.name("path").unwrap().as_str().to_string(),
            ) {
                break;
            };
        }
    }
}
/// Allows one to walk the mappings in /proc/self/maps, caling a callback function for each
/// mapping.
/// If the callback returns true, we stop the walk.
Allows one to walk the mappings in /proc/self/maps, caling a callback function for each
mapping.
If the callback returns true, we stop the walk.
Allows one to walk the mappings in / proc / self / maps caling a callback function for each mapping . If the callback returns true we stop the walk .
fn walk_self_maps(visitor: &mut dyn FnMut(usize, usize, String, String) -> bool) {
    let re = Regex::new(r"^(?P<start>[0-9a-f]{8,16})-(?P<end>[0-9a-f]{8,16}) (?P<perm>[-rwxp]{4}) (?P<offset>[0-9a-f]{8}) [0-9a-f]+:[0-9a-f]+ [0-9]+\s+(?P<path>.*)$")
        .unwrap();
    let mapsfile = File::open("/proc/self/maps").expect("Unable to open /proc/self/maps");
    for line in BufReader::new(mapsfile).lines() {
        let line = line.unwrap();
        if let Some(caps) = re.captures(&line) {
            if visitor(
                usize::from_str_radix(caps.name("start").unwrap().as_str(), 16).unwrap(),
                usize::from_str_radix(caps.name("end").unwrap().as_str(), 16).unwrap(),
                caps.name("perm").unwrap().as_str().to_string(),
                caps.name("path").unwrap().as_str().to_string(),
            ) {
                break;
            };
        }
    }
}
fn walk_self_maps ( visitor : & mut dyn FnMut ( usize , usize , String , String ) -> bool ) { let re = Regex :: new ( r"^(?P<start>[0-9a-f]{8,16})-(?P<end>[0-9a-f]{8,16}) (?P<perm>[-rwxp]{4}) (?P<offset>[0-9a-f]{8}) [0-9a-f]+:[0-9a-f]+ [0-9]+\s+(?P<path>.*)$" ) . unwrap ( ) ; let mapsfile = File :: open ( " " ) . expect ( " " ) ; for line in BufReader :: new ( mapsfile ) . lines ( ) { let line = line . unwrap ( ) ; if let Some ( caps ) = re . captures ( & line ) { if visitor ( usize :: from_str_radix ( caps . name ( " " ) . unwrap ( ) . as_str ( ) , 16 ) . unwrap ( ) , usize :: from_str_radix ( caps . name ( " " ) . unwrap ( ) . as_str ( ) , 16 ) . unwrap ( ) , caps . name ( " " ) . unwrap ( ) . as_str ( ) . to_string ( ) , caps . name ( " " ) . unwrap ( ) . as_str ( ) . to_string ( ) , ) { break ; } ; } } }
Allows one to walk the mappings in /proc/self/maps, caling a callback function for each
mapping.
Allows one to walk the mappings in / proc / self / maps caling a callback function for each mapping .
visitor
&mut dyn FnMut(usize, usize, String, String) -> bool
visitor
&mut dyn FnMut(usize, usize, String, String) -> bool