Skip to content

Commit 985caaa

Browse files
committed
thanks clippy
1 parent 8d84818 commit 985caaa

File tree

21 files changed

+32
-32
lines changed

21 files changed

+32
-32
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,3 +394,4 @@ stable_sort_primitive = "allow" # x1
394394
no_effect_underscore_binding = "allow" # x1
395395
empty_docs = "allow"
396396
too_long_first_doc_paragraph = "allow"
397+
large_stack_arrays = "allow"

gitoxide-core/src/repository/attributes/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ pub(crate) mod function {
8989
let entry = cache.at_entry(
9090
path,
9191
Some(is_dir_to_mode(
92-
workdir.map_or(false, |wd| wd.join(gix::path::from_bstr(path)).is_dir())
92+
workdir.is_some_and(|wd| wd.join(gix::path::from_bstr(path)).is_dir())
9393
|| pattern.signature.contains(gix::pathspec::MagicSignature::MUST_BE_DIR),
9494
)),
9595
)?;

gitoxide-core/src/repository/clean.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,10 @@ pub(crate) mod function {
128128
let pathspec_includes_entry = match pathspec.as_mut() {
129129
None => entry
130130
.pathspec_match
131-
.map_or(false, |m| m != gix::dir::entry::PathspecMatch::Excluded),
131+
.is_some_and(|m| m != gix::dir::entry::PathspecMatch::Excluded),
132132
Some(pathspec) => pathspec
133133
.pattern_matching_relative_path(entry.rela_path.as_bstr(), entry.disk_kind.map(|k| k.is_dir()))
134-
.map_or(false, |m| !m.is_excluded()),
134+
.is_some_and(|m| !m.is_excluded()),
135135
};
136136
pruned_entries += usize::from(!pathspec_includes_entry);
137137
if !pathspec_includes_entry && debug {

gitoxide-core/src/repository/config.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn list(
3232
}
3333

3434
let meta = section.meta();
35-
if last_meta.map_or(true, |last| last != meta) {
35+
if last_meta != Some(meta) {
3636
write_meta(meta, &mut out)?;
3737
}
3838
last_meta = Some(meta);
@@ -41,9 +41,10 @@ pub fn list(
4141
for event in matter {
4242
event.write_to(&mut out)?;
4343
}
44-
if it.peek().map_or(false, |(next_section, _)| {
45-
next_section.header().name() != section.header().name()
46-
}) {
44+
if it
45+
.peek()
46+
.is_some_and(|(next_section, _)| next_section.header().name() != section.header().name())
47+
{
4748
writeln!(&mut out)?;
4849
}
4950
}

gitoxide-core/src/repository/exclude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn query(
9393
let entry = cache.at_entry(
9494
path,
9595
Some(is_dir_to_mode(
96-
workdir.map_or(false, |wd| wd.join(gix::path::from_bstr(path)).is_dir())
96+
workdir.is_some_and(|wd| wd.join(gix::path::from_bstr(path)).is_dir())
9797
|| pattern.signature.contains(gix::pathspec::MagicSignature::MUST_BE_DIR),
9898
)),
9999
)?;

gitoxide-core/src/repository/fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ pub(crate) mod function {
305305
for fix in &map.fixes {
306306
match fix {
307307
Fix::MappingWithPartialDestinationRemoved { name, spec } => {
308-
if prev_spec.map_or(true, |prev_spec| prev_spec != spec) {
308+
if prev_spec.is_some_and(|prev_spec| prev_spec != spec) {
309309
prev_spec = spec.into();
310310
spec.to_ref().write_to(&mut err)?;
311311
writeln!(err)?;

gitoxide-core/src/repository/index/entries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub(crate) mod function {
198198
sms_by_path
199199
.iter()
200200
.find_map(|(path, sm)| (path == entry_path).then_some(sm))
201-
.filter(|sm| sm.git_dir_try_old_form().map_or(false, |dot_git| dot_git.exists()))
201+
.filter(|sm| sm.git_dir_try_old_form().is_ok_and(|dot_git| dot_git.exists()))
202202
})
203203
{
204204
let sm_path = gix::path::to_unix_separators_on_windows(sm.path()?);

gitoxide-core/src/repository/remote.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ mod refs_impl {
190190
for fix in &map.fixes {
191191
match fix {
192192
Fix::MappingWithPartialDestinationRemoved { name, spec } => {
193-
if prev_spec.map_or(true, |prev_spec| prev_spec != spec) {
193+
if prev_spec.is_some_and(|prev_spec| prev_spec != spec) {
194194
prev_spec = spec.into();
195195
spec.to_ref().write_to(&mut err)?;
196196
writeln!(err)?;

gitoxide-core/src/repository/revision/list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub(crate) mod function {
108108
}
109109
}
110110
progress.inc();
111-
if limit.map_or(false, |limit| limit == progress.step()) {
111+
if limit.is_some_and(|limit| limit == progress.step()) {
112112
break;
113113
}
114114
}

gix-dir/src/walk/classify.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ pub fn path(
215215

216216
let is_dir = if symlinks_to_directories_are_ignored_like_directories
217217
&& ctx.excludes.is_some()
218-
&& kind.map_or(false, |ft| ft == entry::Kind::Symlink)
218+
&& kind == Some(entry::Kind::Symlink)
219219
{
220220
path.metadata().ok().map(|md| is_dir_to_mode(md.is_dir()))
221221
} else {

gix-filter/examples/arrow.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1919

2020
match sub_command.as_str() {
2121
"process" => {
22-
let disallow_delay = next_arg.as_deref().map_or(false, |arg| arg == "disallow-delay");
22+
let disallow_delay = next_arg.as_deref() == Some("disallow-delay");
2323
let mut srv = gix_filter::driver::process::Server::handshake(
2424
stdin(),
2525
stdout(),

gix-filter/src/driver/process/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ impl Status {
8383

8484
/// Returns true if this is an `abort` status.
8585
pub fn is_abort(&self) -> bool {
86-
self.message().map_or(false, |m| m == "abort")
86+
self.message() == Some("abort")
8787
}
8888

8989
/// Return true if the status is explicitly set to indicated delayed output processing

gix-pack/src/multi_index/chunk.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub mod index_names {
6969
ascii_path.is_ascii(),
7070
"must use ascii bytes for correct size computation"
7171
);
72-
count += (ascii_path.as_bytes().len() + 1/* null byte */) as u64;
72+
count += (ascii_path.len() + 1/* null byte */) as u64;
7373
}
7474

7575
let needed_alignment = CHUNK_ALIGNMENT - (count % CHUNK_ALIGNMENT);
@@ -89,7 +89,7 @@ pub mod index_names {
8989
let path = path.as_ref().to_str().expect("UTF-8 path");
9090
out.write_all(path.as_bytes())?;
9191
out.write_all(&[0])?;
92-
written_bytes += path.as_bytes().len() as u64 + 1;
92+
written_bytes += path.len() as u64 + 1;
9393
}
9494

9595
let needed_alignment = CHUNK_ALIGNMENT - (written_bytes % CHUNK_ALIGNMENT);

gix-packetline-blocking/src/line/async_io.rs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gix-packetline/src/line/async_io.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ impl<'a> BandRef<'a> {
1818
}
1919
}
2020

21-
impl<'a> TextRef<'a> {
21+
impl TextRef<'_> {
2222
/// Serialize this instance to `out`, appending a newline if there is none, returning the amount of bytes written.
2323
pub async fn write_to(&self, out: impl AsyncWrite + Unpin) -> io::Result<usize> {
2424
encode::text_to_write(self.0, out).await
2525
}
2626
}
2727

28-
impl<'a> ErrorRef<'a> {
28+
impl ErrorRef<'_> {
2929
/// Serialize this line as error to `out`.
3030
///
3131
/// This includes a marker to allow decoding it outside of a side-band channel, returning the amount of bytes written.
@@ -34,7 +34,7 @@ impl<'a> ErrorRef<'a> {
3434
}
3535
}
3636

37-
impl<'a> PacketLineRef<'a> {
37+
impl PacketLineRef<'_> {
3838
/// Serialize this instance to `out` in git `packetline` format, returning the amount of bytes written to `out`.
3939
pub async fn write_to(&self, out: impl AsyncWrite + Unpin) -> io::Result<usize> {
4040
match self {

gix-ref/src/store/file/transaction/commit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl Transaction<'_, '_> {
7272
}
7373
};
7474
if let Some((previous, new_oid)) = log_update {
75-
let do_update = previous.as_ref().map_or(true, |previous| previous != new_oid);
75+
let do_update = previous.as_ref() != Some(new_oid);
7676
if do_update {
7777
self.store.reflog_create_or_append(
7878
change.update.name.as_ref(),

gix-submodule/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44

55
use std::{borrow::Cow, collections::BTreeMap};
66

7-
use bstr::BStr;
8-
97
/// All relevant information about a git module, typically from `.gitmodules` files.
108
///
119
/// Note that overrides from other configuration might be relevant, which is why this type
@@ -64,7 +62,7 @@ impl File {
6462
let mut config_to_append = gix_config::File::new(config.meta_owned());
6563
let mut prev_name = None;
6664
for ((module_name, field), values) in values {
67-
if prev_name.map_or(true, |pn: &BStr| pn != module_name) {
65+
if prev_name != Some(module_name) {
6866
config_to_append
6967
.new_section("submodule", Some(Cow::Owned(module_name.to_owned())))
7068
.expect("all names come from valid configuration, so remain valid");

gix-validate/src/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ fn check_win_devices_and_illegal_characters(input: &BStr) -> Option<component::E
185185
}
186186

187187
fn is_symlink(mode: Option<component::Mode>) -> bool {
188-
mode.map_or(false, |m| m == component::Mode::Symlink)
188+
mode == Some(component::Mode::Symlink)
189189
}
190190

191191
fn is_dot_hfs(input: &BStr, search_case_insensitive: &str) -> bool {

gix/src/config/tree/sections/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::unnecessary_literal_bound)]
12
#![allow(missing_docs)]
23

34
/// The `author` top-level section.

gix/src/remote/url/scheme_permission.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl SchemePermission {
6363
.map(|value| Protocol::ALLOW.try_into_allow(value, None))
6464
.transpose()?;
6565

66-
let mut saw_user = allow.map_or(false, |allow| allow == Allow::User);
66+
let mut saw_user = allow == Some(Allow::User);
6767
let allow_per_scheme = match config.sections_by_name_and_filter("protocol", &mut filter) {
6868
Some(it) => {
6969
let mut map = BTreeMap::default();

tests/tools/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,7 @@ fn is_lfs_pointer_file(path: &Path) -> bool {
685685
std::fs::OpenOptions::new()
686686
.read(true)
687687
.open(path)
688-
.and_then(|mut f| f.read_exact(&mut buf))
689-
.map_or(false, |_| buf.starts_with(PREFIX))
688+
.is_ok_and(|mut f| f.read_exact(&mut buf).is_ok_and(|_| buf.starts_with(PREFIX)))
690689
}
691690

692691
/// The `script_identity` will be baked into the soon to be created `archive` as it identifies the script

0 commit comments

Comments
 (0)