Skip to content

Commit

Permalink
Use Arc<str> instead of Arc<String>
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-numeus committed Jul 6, 2024
1 parent 01f2b0d commit 916bd4a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions sea-streamer-types/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub const TIMESTAMP_FORMAT: &[time::format_description::FormatItem<'static>] =
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
/// Identifies a stream. Aka. topic.
pub struct StreamKey {
name: Arc<String>,
name: Arc<str>,
}

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
Expand All @@ -37,11 +37,11 @@ pub enum SeqPos {
}

impl StreamKey {
pub fn new<S: Into<String>>(key: S) -> Result<Self, StreamKeyErr> {
let key = key.into();
if is_valid_stream_key(key.as_str()) {
pub fn new<S: AsRef<str>>(key: S) -> Result<Self, StreamKeyErr> {
let key = key.as_ref();
if is_valid_stream_key(key) {
Ok(Self {
name: Arc::new(key),
name: Arc::from(key),
})
} else {
Err(StreamKeyErr::InvalidStreamKey)
Expand Down

0 comments on commit 916bd4a

Please sign in to comment.