4 let _ = (0..4).filter_map(|x| if x > 1 { Some(x) } else { None });
5 let _ = (0..4).filter_map(|x| {
11 let _ = (0..4).filter_map(|x| match x {
16 let _ = (0..4).filter_map(|x| Some(x + 1));
18 let _ = (0..4).filter_map(i32::checked_abs);
21 fn filter_map_none_changes_item_type() -> impl Iterator<Item = bool> {
22 "".chars().filter_map(|_| None)
25 // https://github.com/rust-lang/rust-clippy/issues/4433#issue-483920107
26 mod comment_483920107 {
35 fn severity(&self) -> Severity {
41 warnings: Vec<ServerError>,
45 fn foo(&mut self, server_errors: Vec<ServerError>) {
46 #[allow(unused_variables)]
47 let errors: Vec<ServerError> = server_errors
49 .filter_map(|se| match se.severity() {
50 Severity::Warning => {
51 self.warnings.push(se);
61 // https://github.com/rust-lang/rust-clippy/issues/4433#issuecomment-611006622
62 mod comment_611006622 {
63 struct PendingRequest {
77 fn send_response(&self, _reply_to: u8, _token: u8, _value: Value) -> &Self {
80 fn on_error_warn(&self) -> &Self {
86 pending_requests: Vec<PendingRequest>,
90 fn foo(&mut self, node: Node, now: u8, group_id: u8) {
92 self.pending_requests = self
95 .filter_map(|pending| {
96 if pending.expires <= now {
97 return None; // Expired, remove
100 if pending.group_id == group_id {
101 // Matched - reuse strings and remove
102 node.send_response(pending.reply_to, pending.token, Value::Null)
115 // https://github.com/rust-lang/rust-clippy/issues/4433#issuecomment-621925270
116 // This extrapolation doesn't reproduce the false positive. Additional context seems necessary.
117 mod comment_621925270 {
118 struct Signature(u8);
120 fn foo(sig_packets: impl Iterator<Item = Result<Signature, ()>>) -> impl Iterator<Item = u8> {
121 sig_packets.filter_map(|res| match res {
122 Ok(Signature(sig_packet)) => Some(sig_packet),
128 // https://github.com/rust-lang/rust-clippy/issues/4433#issuecomment-1052978898
129 mod comment_1052978898 {
130 #![allow(clippy::redundant_closure)]
135 pub fn consume(self) {
140 pub fn filter_owned() -> impl Iterator<Item = S> {
141 (0..10).map(|i| S(i)).filter_map(|s| {