Rust's work with file paths

I noticed that when compiling the project, the file paths are taken into account as if the executing file is at the root of the project. For example, if you write fs::read_to_string(“./tests/text.txt") after compilation everything will be successful, and the executing file for tests thinks that it is in the root of project And if you specify ".. /.. /../Tests/text.txt" as the path to the file, the test will fail. Does Rust somehow find all the paths to the files in the source file and optimize them?

No. Relative paths are relative to the current execution/working directory, $PWD, or "where your shell is currently".


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.