Skip to content
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

Prefer returning &str over String where applicable #878

Merged
merged 2 commits into from
Mar 24, 2023
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 async-nats/src/jetstream/kv/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct Status {

impl Status {
/// The name of the bucket
pub fn bucket(&self) -> &String {
pub fn bucket(&self) -> &str {
&self.bucket
}

Expand Down
8 changes: 4 additions & 4 deletions async-nats/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1243,18 +1243,18 @@ impl ServerAddr {
}

/// Returns the optional username in the url.
pub fn username(&self) -> Option<String> {
pub fn username(&self) -> Option<&str> {
let user = self.0.username();
if user.is_empty() {
None
} else {
Some(user.to_string())
Some(user)
}
}

/// Returns the optional password in the url.
pub fn password(&self) -> Option<String> {
self.0.password().map(|pwd| pwd.to_string())
pub fn password(&self) -> Option<&str> {
self.0.password()
}

/// Return the sockets from resolving the server address.
Expand Down