fmt
This commit is contained in:
parent
5007f5ddba
commit
298c0a7f6f
|
@ -101,7 +101,7 @@ impl<'de> Deserialize<'de> for Meme {
|
|||
}
|
||||
|
||||
keyword = Some(map.next_value()?);
|
||||
}
|
||||
},
|
||||
|
||||
Field::Ident(i) => {
|
||||
if ident.is_some() {
|
||||
|
@ -113,12 +113,12 @@ impl<'de> Deserialize<'de> for Meme {
|
|||
match i {
|
||||
IdentField::Id => {
|
||||
ident = Some(MemeIdent::Id(map.next_value()?));
|
||||
}
|
||||
},
|
||||
IdentField::RandomCat => {
|
||||
ident = Some(MemeIdent::RandomCat(map.next_value()?));
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Field::Matcher => {
|
||||
if matcher.is_some() {
|
||||
|
@ -126,7 +126,7 @@ impl<'de> Deserialize<'de> for Meme {
|
|||
}
|
||||
|
||||
matcher = Some(map.next_value()?);
|
||||
}
|
||||
},
|
||||
|
||||
Field::MatchCase => {
|
||||
if match_case.is_some() {
|
||||
|
@ -134,7 +134,7 @@ impl<'de> Deserialize<'de> for Meme {
|
|||
}
|
||||
|
||||
match_case = Some(map.next_value()?);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
13
src/main.rs
13
src/main.rs
|
@ -10,11 +10,14 @@ use matrix_sdk::{
|
|||
member::MemberEventContent,
|
||||
message::{MessageEventContent, MessageType, TextMessageEventContent},
|
||||
},
|
||||
AnyToDeviceEvent, StrippedStateEvent, SyncMessageEvent,
|
||||
AnyToDeviceEvent,
|
||||
StrippedStateEvent,
|
||||
SyncMessageEvent,
|
||||
},
|
||||
room::Room,
|
||||
verification::Verification,
|
||||
EventHandler, LoopCtrl,
|
||||
EventHandler,
|
||||
LoopCtrl,
|
||||
};
|
||||
use rand::{rngs::StdRng, SeedableRng};
|
||||
use sled::Db;
|
||||
|
@ -230,7 +233,7 @@ async fn on_response(response: &SyncResponse, client: &Client) -> anyhow::Result
|
|||
error!("Error accepting key verification request: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
AnyToDeviceEvent::KeyVerificationKey(e) => {
|
||||
if let Some(Verification::SasV1(sas)) = &client
|
||||
|
@ -241,9 +244,9 @@ async fn on_response(response: &SyncResponse, client: &Client) -> anyhow::Result
|
|||
error!("Error confirming key verification request: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_ => {}
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
16
src/meme.rs
16
src/meme.rs
|
@ -36,19 +36,17 @@ impl Meme {
|
|||
msg.starts_with(&keyword) &&
|
||||
// msg must have one of allowed chars after keyword
|
||||
msg.chars().nth(keyword.len()).map(|c| ALLOWED_SPACES.contains(c)).unwrap_or(true)
|
||||
}
|
||||
},
|
||||
|
||||
Matcher::Contains => msg
|
||||
.match_indices(&keyword)
|
||||
.map(|(idx, subs)| {
|
||||
(idx == 0
|
||||
|| msg
|
||||
.chars()
|
||||
(idx == 0 ||
|
||||
msg.chars()
|
||||
.nth(idx - 1)
|
||||
.map(|c| ALLOWED_SPACES.contains(c))
|
||||
.unwrap_or(true))
|
||||
&& msg
|
||||
.chars()
|
||||
.unwrap_or(true)) &&
|
||||
msg.chars()
|
||||
.nth(idx + subs.len())
|
||||
.map(|c| ALLOWED_SPACES.contains(c))
|
||||
.unwrap_or(true)
|
||||
|
@ -76,13 +74,13 @@ impl Meme {
|
|||
&meme.id, &meme
|
||||
);
|
||||
Err(e.into())
|
||||
}
|
||||
},
|
||||
Ok(id) => Ok(Some(id)),
|
||||
}
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@ pub mod mime_serialize {
|
|||
use mime::Mime;
|
||||
use serde::{
|
||||
de::{self, Unexpected, Visitor},
|
||||
Deserializer, Serializer,
|
||||
Deserializer,
|
||||
Serializer,
|
||||
};
|
||||
|
||||
pub fn serialize<S>(data: &Mime, serializer: S) -> Result<S::Ok, S::Error>
|
||||
|
|
Loading…
Reference in a new issue