From f36e6035c8c3785fccd2076329eb7bd4e1d91219 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 16 Dec 2022 21:28:19 -0500 Subject: [PATCH] Change a few methods to take AsRef --- src/fs.rs | 2 +- src/settings/pyproject.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fs.rs b/src/fs.rs index 83ec117a25..e67e52c156 100644 --- a/src/fs.rs +++ b/src/fs.rs @@ -64,7 +64,7 @@ pub fn relativize_path(path: &Path) -> Cow { } /// Read a file's contents from disk. -pub(crate) fn read_file(path: &Path) -> Result { +pub(crate) fn read_file>(path: P) -> Result { let file = File::open(path)?; let mut buf_reader = BufReader::new(file); let mut contents = String::new(); diff --git a/src/settings/pyproject.rs b/src/settings/pyproject.rs index ccece9886d..8ae6690979 100644 --- a/src/settings/pyproject.rs +++ b/src/settings/pyproject.rs @@ -28,13 +28,13 @@ impl Pyproject { } } -fn parse_pyproject_toml(path: &Path) -> Result { +fn parse_pyproject_toml>(path: P) -> Result { let contents = fs::read_file(path)?; toml::from_str(&contents).map_err(std::convert::Into::into) } /// Return `true` if a `pyproject.toml` contains a `[tool.ruff]` section. -pub fn has_ruff_section(path: &Path) -> Result { +pub fn has_ruff_section>(path: P) -> Result { let pyproject = parse_pyproject_toml(path)?; Ok(pyproject.tool.and_then(|tool| tool.ruff).is_some()) }