Skip to content

Commit 6df971d

Browse files
cartUkoeHB
authored andcommitted
Remove span generics
1 parent 9de42f7 commit 6df971d

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

crates/bevy_text/src/text.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
pub use cosmic_text::{
2+
self, FamilyOwned as FontFamily, Stretch as FontStretch, Style as FontStyle,
3+
Weight as FontWeight,
4+
};
5+
6+
use crate::{Font, TextLayoutInfo, TextSpanAccess, TextSpanComponent};
17
use bevy_asset::Handle;
28
use bevy_color::Color;
39
use bevy_derive::{Deref, DerefMut};
@@ -9,12 +15,6 @@ use cosmic_text::{Buffer, Metrics};
915
use serde::{Deserialize, Serialize};
1016
use smallvec::SmallVec;
1117

12-
use crate::{Font, TextLayoutInfo, TextSpanAccess, TextSpanComponent};
13-
pub use cosmic_text::{
14-
self, FamilyOwned as FontFamily, Stretch as FontStretch, Style as FontStyle,
15-
Weight as FontWeight,
16-
};
17-
1818
/// Wrapper for [`cosmic_text::Buffer`]
1919
#[derive(Deref, DerefMut, Debug, Clone)]
2020
pub struct CosmicBuffer(pub Buffer);

crates/bevy_text/src/text2d.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::pipeline::CosmicFontSystem;
22
use crate::{
33
ComputedTextBlock, Font, FontAtlasSets, LineBreak, PositionedGlyph, SwashCache, TextBlock,
4-
TextBounds, TextError, TextLayoutInfo, TextPipeline, TextReader, TextRoot, TextSpan,
5-
TextSpanAccess, TextStyle, TextWriter, YAxisOrientation,
4+
TextBounds, TextError, TextLayoutInfo, TextPipeline, TextReader, TextRoot, TextSpanAccess,
5+
TextStyle, TextWriter, YAxisOrientation,
66
};
77
use bevy_asset::Assets;
88
use bevy_color::LinearRgba;
@@ -95,9 +95,7 @@ impl Text2d {
9595
}
9696
}
9797

98-
impl TextRoot for Text2d {
99-
type Span = TextSpan;
100-
}
98+
impl TextRoot for Text2d {}
10199

102100
impl TextSpanAccess for Text2d {
103101
fn read_span(&self) -> &str {

crates/bevy_text/src/text_access.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bevy_ecs::{
44
};
55
use bevy_hierarchy::Children;
66

7-
use crate::TextStyle;
7+
use crate::{TextSpan, TextStyle};
88

99
/// Helper trait for using the [`TextReader`] and [`TextWriter`] system params.
1010
pub trait TextSpanAccess: Component {
@@ -15,10 +15,7 @@ pub trait TextSpanAccess: Component {
1515
}
1616

1717
/// Helper trait for the root text component in a text block.
18-
pub trait TextRoot: TextSpanAccess + From<String> {
19-
/// Component type for spans of text blocks starting with the root component.
20-
type Span: TextSpanComponent;
21-
}
18+
pub trait TextRoot: TextSpanAccess + From<String> {}
2219

2320
/// Helper trait for the text span components in a text block.
2421
pub trait TextSpanComponent: TextSpanAccess + From<String> {}
@@ -56,7 +53,7 @@ pub struct TextReader<'w, 's, R: TextRoot> {
5653
'w,
5754
's,
5855
(
59-
&'static <R as TextRoot>::Span,
56+
&'static TextSpan,
6057
&'static TextStyle,
6158
Option<&'static Children>,
6259
),
@@ -126,7 +123,7 @@ pub struct TextSpanIter<'a, R: TextRoot> {
126123
'a,
127124
'a,
128125
(
129-
&'static <R as TextRoot>::Span,
126+
&'static TextSpan,
130127
&'static TextStyle,
131128
Option<&'static Children>,
132129
),
@@ -195,8 +192,8 @@ impl<'a, R: TextRoot> Drop for TextSpanIter<'a, R> {
195192
#[derive(SystemParam)]
196193
pub struct TextWriter<'w, 's, R: TextRoot> {
197194
scratch: ResMut<'w, TextIterScratch>,
198-
roots: Query<'w, 's, (&'static mut R, &'static mut TextStyle), Without<<R as TextRoot>::Span>>,
199-
spans: Query<'w, 's, (&'static mut <R as TextRoot>::Span, &'static mut TextStyle), Without<R>>,
195+
roots: Query<'w, 's, (&'static mut R, &'static mut TextStyle), Without<TextSpan>>,
196+
spans: Query<'w, 's, (&'static mut TextSpan, &'static mut TextStyle), Without<R>>,
200197
children: Query<'w, 's, &'static Children>,
201198
}
202199

crates/bevy_ui/src/widget/text.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use bevy_sprite::TextureAtlasLayout;
2020
use bevy_text::{
2121
scale_value, ComputedTextBlock, CosmicFontSystem, Font, FontAtlasSets, LineBreak, SwashCache,
2222
TextBlock, TextBounds, TextError, TextLayoutInfo, TextMeasureInfo, TextPipeline, TextReader,
23-
TextRoot, TextSpan, TextSpanAccess, TextStyle, TextWriter, YAxisOrientation,
23+
TextRoot, TextSpanAccess, TextStyle, TextWriter, YAxisOrientation,
2424
};
2525
use bevy_transform::components::Transform;
2626
use bevy_utils::{tracing::error, Entry};
@@ -116,9 +116,7 @@ impl Text {
116116
}
117117
}
118118

119-
impl TextRoot for Text {
120-
type Span = TextSpan;
121-
}
119+
impl TextRoot for Text {}
122120

123121
impl TextSpanAccess for Text {
124122
fn read_span(&self) -> &str {

0 commit comments

Comments
 (0)