7322: Use assert_never properly r=matklad a=matklad

bors r+
🤖

Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2021-01-18 12:58:54 +00:00 committed by GitHub
commit 1b5405620f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -398,7 +398,9 @@ impl Builder {
pub(crate) fn set_detail(mut self, detail: Option<impl Into<String>>) -> Builder {
self.detail = detail.map(Into::into);
if let Some(detail) = &self.detail {
assert_never!(detail.contains('\n'), "multiline detail: {}", detail);
if assert_never!(detail.contains('\n'), "multiline detail: {}", detail) {
self.detail = Some(detail.splitn(2, '\n').next().unwrap().to_string());
}
}
self
}