mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-08 19:43:11 +00:00
f0ef63bfa0
This PR adds a `SharedUrl` type to GPUI. It's just like a `SharedString`, but for denoting that the contained value is a URL. Mainlined from @nathansobo's GPUI blog post: https://github.com/zed-industries/zed/pull/3968/files#diff-7ee75937e2daf7dd53f71b17698d8bd6d46993d06928d411781b9bd739b5f231R9-R12 Release Notes: - N/A
25 lines
627 B
Rust
25 lines
627 B
Rust
use derive_more::{Deref, DerefMut};
|
|
|
|
use crate::SharedString;
|
|
|
|
/// A [`SharedString`] containing a URL.
|
|
#[derive(Deref, DerefMut, Default, PartialEq, Eq, Hash, Clone)]
|
|
pub struct SharedUrl(SharedString);
|
|
|
|
impl std::fmt::Debug for SharedUrl {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
self.0.fmt(f)
|
|
}
|
|
}
|
|
|
|
impl std::fmt::Display for SharedUrl {
|
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
write!(f, "{}", self.0.as_ref())
|
|
}
|
|
}
|
|
|
|
impl<T: Into<SharedString>> From<T> for SharedUrl {
|
|
fn from(value: T) -> Self {
|
|
Self(value.into())
|
|
}
|
|
}
|