Bump our MSRV to 1.45.2

This commit is contained in:
Paolo Barbolini
2020-10-10 11:55:44 +02:00
parent 0174a29a45
commit ed9ca92de8
4 changed files with 17 additions and 21 deletions

View File

@@ -11,7 +11,7 @@ jobs:
rust:
- stable
- beta
- 1.40.0
- 1.45.2
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
@@ -37,7 +37,6 @@ jobs:
args: --no-default-features --features=builder,smtp-transport,file-transport,sendmail-transport
- run: rm target/debug/deps/liblettre-*
- uses: actions-rs/cargo@v1
if: matrix.rust != '1.40.0'
with:
command: test
args: --features=async-std1
@@ -54,7 +53,7 @@ jobs:
rust:
- stable
- beta
- 1.40.0
- 1.45.2
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1

View File

@@ -53,7 +53,7 @@ Lettre does not provide (for now):
## Example
This library requires Rust 1.40 or newer.
This library requires Rust 1.45 or newer.
To use this library, add the following to your `Cargo.toml`:

View File

@@ -16,19 +16,16 @@ pub fn encode(s: &str) -> String {
}
pub fn decode(s: &str) -> Option<String> {
const PREFIX: &str = "=?utf-8?b?";
const SUFFIX: &str = "?=";
let s = s.trim();
if s.starts_with(PREFIX) && s.ends_with(SUFFIX) {
let s = &s[PREFIX.len()..];
let s = &s[..s.len() - SUFFIX.len()];
base64::decode(s)
.ok()
.and_then(|v| String::from_utf8(v).ok())
} else {
Some(s.into())
}
s.strip_prefix("=?utf-8?b?")
.and_then(|stripped| stripped.strip_suffix("?="))
.map_or_else(
|| Some(s.into()),
|stripped| {
let decoded = base64::decode(stripped).ok()?;
let decoded = String::from_utf8(decoded).ok()?;
Some(decoded)
},
)
}
#[cfg(test)]

View File

@@ -151,10 +151,10 @@ impl Response {
/// Tells if the response is positive
pub fn is_positive(&self) -> bool {
match self.code.severity {
Severity::PositiveCompletion | Severity::PositiveIntermediate => true,
_ => false,
}
matches!(
self.code.severity,
Severity::PositiveCompletion | Severity::PositiveIntermediate
)
}
/// Tests code equality