Rename with_id, with_type_id to id, type_id. (#153)

This commit is contained in:
Jason Lee 2024-08-15 18:05:07 +08:00 committed by GitHub
parent a02a6ed6b8
commit 57dab4d15a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 5 deletions

View file

@ -501,7 +501,7 @@ impl Render for ModalStory {
Notification::new(
"你已经成功保存了文件,但是有一些警告信息需要你注意。",
)
.with_type_id::<TestNotification>()
.type_id::<TestNotification>()
.title("保存成功")
.icon(IconName::Inbox)
.autohide(false)

View file

@ -100,7 +100,7 @@ impl Notification {
}
/// Set the id of the notification, used to uniquely identify the notification.
pub fn with_id(mut self, id: impl Into<SharedString>) -> Self {
pub fn id(mut self, id: impl Into<SharedString>) -> Self {
let id: SharedString = id.into();
self.id = id.into();
self
@ -110,9 +110,9 @@ impl Notification {
///
/// ```rs
/// struct MyNotificationKind;
/// let notification = Notification::new("Hello").with_type_id::<MyNotificationKind>();
/// let notification = Notification::new("Hello").type_id::<MyNotificationKind>();
/// ```
pub fn with_type_id<T: Sized + 'static>(mut self) -> Self {
pub fn type_id<T: Sized + 'static>(mut self) -> Self {
let type_id = TypeId::of::<T>();
self.id = type_id.into();
self
@ -134,7 +134,7 @@ impl Notification {
self
}
pub fn with_type(mut self, type_: NotificationType) -> Self {
fn with_type(mut self, type_: NotificationType) -> Self {
self.type_ = type_;
self
}