Skip to content

Commit

Permalink
Rename CoreData -> DefaultCoreType and hide
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Jan 23, 2025
1 parent 6aec871 commit 2ec2d2d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
12 changes: 5 additions & 7 deletions crates/kas-core/src/core/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,19 @@ impl Icon {
/// Common widget data
///
/// This type may be used for a [`Widget`]'s `core: widget_core!()` field.
#[cfg_attr(not(feature = "internal_doc"), doc(hidden))]
#[cfg_attr(docsrs, doc(cfg(internal_doc)))]
#[derive(Default, Debug)]
pub struct CoreData {
pub struct DefaultCoreType {
pub _rect: Rect,
pub _id: Id,
#[cfg_attr(not(feature = "internal_doc"), doc(hidden))]
#[cfg_attr(docsrs, doc(cfg(internal_doc)))]
#[cfg(debug_assertions)]
pub status: WidgetStatus,
}

/// Note: the clone has default-initialised identifier.
/// Configuration and layout solving is required as for any other widget.
impl Clone for CoreData {
impl Clone for DefaultCoreType {
fn clone(&self) -> Self {
CoreData {
DefaultCoreType {
_rect: self._rect,
_id: Default::default(),
status: self.status,
Expand Down
10 changes: 2 additions & 8 deletions crates/kas-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,8 @@ pub fn impl_scope(input: TokenStream) -> TokenStream {
/// The struct must contain a field of type `widget_core!()` (usually named
/// `core`). The macro `widget_core!()` is a placeholder, expanded by
/// `#[widget]` and used to identify the field used (any name may be used).
/// This field *might* have type [`CoreData`] or might use a special generated
/// type; either way it has fields `id: Id` (assigned by during configure)
/// and `rect: Rect` (usually assigned by
/// `Layout::set_rect`). It may contain additional fields for layout data. The
/// type supports `Default` and `Clone` (although `Clone` actually
/// default-initializes all fields other than `rect` since clones of widgets
/// must themselves be configured).
/// This type implements [`Default`] and [`Clone`], though the clone is not an
/// exact clone (cloned widgets must still be configured).
///
/// Assuming the deriving type is a `struct` or `tuple struct`, fields support
/// the following attributes:
Expand Down Expand Up @@ -359,7 +354,6 @@ pub fn impl_scope(input: TokenStream) -> TokenStream {
/// [`Events`]: https://docs.rs/kas/latest/kas/trait.Events.html
/// [`CursorIcon`]: https://docs.rs/kas/latest/kas/event/enum.CursorIcon.html
/// [`IsUsed`]: https://docs.rs/kas/latest/kas/event/enum.IsUsed.html
/// [`CoreData`]: https://docs.rs/kas/latest/kas/struct.CoreData.html
/// [`Deref`]: std::ops::Deref
#[proc_macro_attribute]
#[proc_macro_error]
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-macros/src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn widget(attr_span: Span, mut args: WidgetArgs, scope: &mut Scope) -> Resul
path: core_type.into(),
});
} else {
field.ty = parse_quote! { ::kas::CoreData };
field.ty = parse_quote! { ::kas::DefaultCoreType };
}

continue;
Expand Down

0 comments on commit 2ec2d2d

Please sign in to comment.