xref: /aosp_15_r20/external/bazelbuild-rules_rust/examples/hello_runfiles/hello_runfiles.rs (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1 use std::fs::File;
2 use std::io::prelude::*;
3 
4 use runfiles::Runfiles;
5 
main()6 fn main() {
7     let r = Runfiles::create().unwrap();
8 
9     let mut f = File::open(runfiles::rlocation!(
10         r,
11         "examples/hello_runfiles/hello_runfiles.rs"
12     ))
13     .unwrap();
14 
15     let mut buffer = String::new();
16     f.read_to_string(&mut buffer).unwrap();
17 
18     println!("This program's source is {} characters long.", buffer.len());
19 }
20