Remove From<LogCollector> for Vec<String> (#33012)

This commit is contained in:
Ryo Onodera 2023-08-27 13:10:02 +09:00 committed by GitHub
parent dbe4017143
commit d3fb54e0b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -54,11 +54,9 @@ impl LogCollector {
..Self::default() ..Self::default()
})) }))
} }
}
impl From<LogCollector> for Vec<String> { pub fn into_messages(self) -> Vec<String> {
fn from(log_collector: LogCollector) -> Self { self.messages
log_collector.messages
} }
} }
@ -114,7 +112,7 @@ pub(crate) mod tests {
lc.log("x"); lc.log("x");
} }
let logs: Vec<_> = lc.into(); let logs: Vec<_> = lc.into_messages();
assert_eq!(logs.len(), LOG_MESSAGES_BYTES_LIMIT); assert_eq!(logs.len(), LOG_MESSAGES_BYTES_LIMIT);
for log in logs.iter().take(LOG_MESSAGES_BYTES_LIMIT - 1) { for log in logs.iter().take(LOG_MESSAGES_BYTES_LIMIT - 1) {
assert_eq!(*log, "x".to_string()); assert_eq!(*log, "x".to_string());

View File

@ -4895,7 +4895,7 @@ impl Bank {
let log_messages: Option<TransactionLogMessages> = let log_messages: Option<TransactionLogMessages> =
log_collector.and_then(|log_collector| { log_collector.and_then(|log_collector| {
Rc::try_unwrap(log_collector) Rc::try_unwrap(log_collector)
.map(|log_collector| log_collector.into_inner().into()) .map(|log_collector| log_collector.into_inner().into_messages())
.ok() .ok()
}); });