Skip to content

Replace str_split_once to lower actix-tls msrv to 1.50.0 and bump actix-net to 1.50.0 #434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion actix-tls/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Changes

## Unreleased - 2021-xx-xx

- Remove use of `str::split_once` to lower MSRV of `actix-tls` to a de-facto 1.50.0 from 1.52.0

## 3.0.0 - 2021-12-26
* No significant changes since `3.0.0-rc.2`.
Expand Down
16 changes: 12 additions & 4 deletions actix-tls/src/connect/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,25 @@ pub trait Host: Unpin + 'static {

impl Host for String {
fn hostname(&self) -> &str {
self.split_once(':')
str_split_once(self, ':')
.map(|(hostname, _)| hostname)
.unwrap_or(self)
}

fn port(&self) -> Option<u16> {
self.split_once(':').and_then(|(_, port)| port.parse().ok())
str_split_once(self, ':').and_then(|(_, port)| port.parse().ok())
}
}

impl Host for &'static str {
fn hostname(&self) -> &str {
self.split_once(':')
str_split_once(self, ':')
.map(|(hostname, _)| hostname)
.unwrap_or(self)
}

fn port(&self) -> Option<u16> {
self.split_once(':').and_then(|(_, port)| port.parse().ok())
str_split_once(self, ':').and_then(|(_, port)| port.parse().ok())
}
}

Expand All @@ -69,3 +69,11 @@ mod tests {
assert_connection_info_eq!("example.com:false:false", "example.com", None);
}
}

// `str::split_once` is stabilized in 1.52.0
fn str_split_once(str: &str, delimiter: char) -> Option<(&str, &str)> {
let mut splitn = str.splitn(2, delimiter);
let prefix = splitn.next()?;
let suffix = splitn.next()?;
Some((prefix, suffix))
}