Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use self #5

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/dashboard/src/widgets/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl Map {
if let Some(controller) = controller.into() {
controller.bind(channel.clone());
}
Map {
Self {
channel,
camera: camera.clone(),
}
Expand Down Expand Up @@ -209,7 +209,7 @@ impl MapState {
channel: Channel<MapCommand>,
sender: Sender<MapCommand>,
) -> Self {
MapState {
Self {
texture,
channel,
sender,
Expand Down Expand Up @@ -245,7 +245,7 @@ unsafe impl Send for RenderMap {}

impl RenderMap {
pub fn new(receiver: Receiver<MapCommand>) -> Self {
RenderMap {
Self {
receiver,
map: None,
last_size: None,
Expand Down
6 changes: 3 additions & 3 deletions examples/dashboard/src/widgets/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ impl Metric {
color: impl Into<Color>,
value: f32,
) -> Self {
Metric {
Self {
level,
suffix: suffix.as_ref().to_string(),
description: description.as_ref().to_string(),
Expand Down Expand Up @@ -124,7 +124,7 @@ struct MetricState {

impl MetricState {
pub fn new(level: i32, value: f32) -> Self {
MetricState {
Self {
animation: None,
level: Tween::new(0, level),
value: Tween::new(0.0, value),
Expand All @@ -149,7 +149,7 @@ pub struct Metrics {}

impl Metrics {
pub fn new() -> Self {
Metrics {}
Self {}
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/dashboard/src/widgets/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Navigation {}

impl Navigation {
pub fn new() -> Self {
Navigation {}
Self {}
}
}

Expand Down Expand Up @@ -68,7 +68,7 @@ struct NavigationState {

impl NavigationState {
pub fn new() -> Self {
NavigationState {
Self {
map: MapController::new(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions examples/dashboard/src/widgets/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub struct Sensor {

impl Sensor {
pub fn new(level: f32) -> Self {
Sensor { level }
Self { level }
}
}

Expand Down Expand Up @@ -81,7 +81,7 @@ struct SensorState {

impl SensorState {
pub fn new() -> Self {
SensorState { animation: None }
Self { animation: None }
}

pub fn animation(&self) -> Option<f32> {
Expand All @@ -94,7 +94,7 @@ pub struct Sensors {}

impl Sensors {
pub fn new() -> Self {
Sensors {}
Self {}
}

fn build_sensor_data(&self, title: impl AsRef<str>) -> impl Widget {
Expand Down
4 changes: 2 additions & 2 deletions examples/dashboard/src/widgets/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub struct Sidebar {}

impl Sidebar {
pub fn new() -> Self {
Sidebar {}
Self {}
}

fn build_button(
Expand Down Expand Up @@ -151,7 +151,7 @@ struct SidebarState {

impl SidebarState {
pub fn new() -> Self {
SidebarState {
Self {
selected_button: Button::Earth,
}
}
Expand Down
8 changes: 4 additions & 4 deletions examples/dashboard/src/widgets/topbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Tab {
title: impl AsRef<str>,
selected: bool,
) -> Self {
Tab {
Self {
title: title.as_ref().to_string(),
selected,
}
Expand Down Expand Up @@ -151,7 +151,7 @@ struct TabState {

impl TabState {
pub fn new(selected: bool) -> Self {
TabState {
Self {
animation: None,
selected,
}
Expand All @@ -167,7 +167,7 @@ pub struct Topbar {}

impl Topbar {
pub fn new() -> Self {
Topbar {}
Self {}
}

fn build_tab(
Expand Down Expand Up @@ -273,7 +273,7 @@ struct TopbarState {

impl TopbarState {
pub fn new() -> Self {
TopbarState {
Self {
selected_button: Button::RealTime,
}
}
Expand Down
6 changes: 3 additions & 3 deletions terramach/graphics/src/gl/android_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Context {

pub fn new_shared(&mut self) -> Self {
let config = egl::android_choose_config(self.inner.display);
Context {
Self {
inner: Rc::new(EGLContext {
owner: true,
context: egl::android_new_context(self.inner.display, config),
Expand Down Expand Up @@ -100,7 +100,7 @@ impl Context {

impl Clone for Context {
fn clone(&self) -> Self {
Context {
Self {
inner: self.inner.clone(),
guard: None,
}
Expand All @@ -126,7 +126,7 @@ impl ContextGuard {
context.inner.context,
);
debug_assert!(result);
ContextGuard {
Self {
current_context,
current_read_surface,
current_draw_surface,
Expand Down
2 changes: 1 addition & 1 deletion terramach/graphics/src/gl/mac_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ impl Context {

impl Clone for Context {
fn clone(&self) -> Self {
Context {
Self {
inner: self.inner.clone(),
guard: None,
}
Expand Down
8 changes: 4 additions & 4 deletions terramach/ui/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<T> Animation<T> {
D: 'static + Driver,
A: 'static + Animated<T>,
{
Animation {
Self {
driver: Box::new(driver),
animated: Box::new(animated),
interpolation: None,
Expand Down Expand Up @@ -115,7 +115,7 @@ pub struct DurationDriver {

impl DurationDriver {
pub fn new(duration: Duration) -> Self {
DurationDriver {
Self {
timestamp: None,
value: 0.0,
duration,
Expand Down Expand Up @@ -167,7 +167,7 @@ pub struct Tween<T: Animated<T>> {

impl<T: Animated<T>> Tween<T> {
pub fn new(begin: impl Into<T>, end: impl Into<T>) -> Self {
Tween {
Self {
begin: begin.into(),
end: end.into(),
}
Expand All @@ -188,7 +188,7 @@ impl<T: Animated<T>> Animated<T> for Tween<T> {

impl<T: Animated<T>> From<(T, T)> for Tween<T> {
fn from(values: (T, T)) -> Self {
Tween::new(values.0, values.1)
Self::new(values.0, values.1)
}
}

Expand Down
2 changes: 1 addition & 1 deletion terramach/ui/common/index_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pub struct IndexPool {

impl IndexPool {
pub fn new() -> Self {
IndexPool {
Self {
current_index: 0,
free_indexes: Vec::new(),
}
Expand Down
4 changes: 2 additions & 2 deletions terramach/ui/common/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct Node<T> {

impl<T> Node<T> {
pub fn new(id: Id, data: impl Into<Option<T>>) -> Self {
Node {
Self {
id,
inner: data.into(),
}
Expand Down Expand Up @@ -75,7 +75,7 @@ impl<T> Tree<T> {
let root = indices.take();
let mut nodes = HashMap::new();
nodes.insert(root, Node::new(root, None));
Tree {
Self {
ids: indices,
root,
nodes,
Expand Down
6 changes: 3 additions & 3 deletions terramach/ui/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct EventContext {

impl EventContext {
pub fn new(event: Event) -> Self {
EventContext {
Self {
need_layout: false,
need_paint: false,
need_build: false,
Expand Down Expand Up @@ -122,7 +122,7 @@ pub type AppEvents = Events<AppEvent>;

impl Default for AppEvents {
fn default() -> Self {
AppEvents::new()
Self::new()
}
}

Expand All @@ -135,7 +135,7 @@ pub struct Events<T> {

impl<T> Events<T> {
pub fn new() -> Self {
Events {
Self {
queue: Default::default(),
}
}
Expand Down
20 changes: 10 additions & 10 deletions terramach/ui/gesture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct TapGesture {

impl TapGesture {
pub fn new(touches_count: usize, tap_count: usize) -> Self {
TapGesture {
Self {
touches_count,
tap_count,
start_touches_count: 0,
Expand Down Expand Up @@ -82,13 +82,13 @@ impl TapGesture {

impl Default for TapGesture {
fn default() -> Self {
TapGesture::new(1, 1)
Self::new(1, 1)
}
}

impl Clone for TapGesture {
fn clone(&self) -> Self {
TapGesture::new(self.touches_count, self.tap_count)
Self::new(self.touches_count, self.tap_count)
}
}

Expand All @@ -109,7 +109,7 @@ pub struct PanGesture {

impl PanGesture {
pub fn new(minimum_touches: usize, maximum_touches: usize) -> Self {
PanGesture {
Self {
minimum_touches,
maximum_touches,
start_location: None,
Expand All @@ -118,7 +118,7 @@ impl PanGesture {
}

pub fn limit(touches_count: usize) -> Self {
PanGesture::new(touches_count, touches_count)
Self::new(touches_count, touches_count)
}

pub fn is_active(&self) -> bool {
Expand Down Expand Up @@ -172,13 +172,13 @@ impl PanGesture {

impl Default for PanGesture {
fn default() -> Self {
PanGesture::new(1, 10)
Self::new(1, 10)
}
}

impl Clone for PanGesture {
fn clone(&self) -> Self {
PanGesture::new(self.minimum_touches, self.maximum_touches)
Self::new(self.minimum_touches, self.maximum_touches)
}
}

Expand Down Expand Up @@ -222,7 +222,7 @@ pub struct PinchGesture {

impl PinchGesture {
pub fn new() -> Self {
PinchGesture {
Self {
state: PinchGestureState::Possible,
start_distance: None,
center_location: None,
Expand Down Expand Up @@ -304,12 +304,12 @@ impl PinchGesture {

impl Default for PinchGesture {
fn default() -> Self {
PinchGesture::new()
Self::new()
}
}

impl Clone for PinchGesture {
fn clone(&self) -> Self {
PinchGesture::new()
Self::new()
}
}
2 changes: 1 addition & 1 deletion terramach/ui/gpu/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub struct Frame {

impl Frame {
pub fn new(layers: &LayerTree) -> Self {
Frame {
Self {
layers: layers.clone(),
}
}
Expand Down
6 changes: 3 additions & 3 deletions terramach/ui/gpu/gl_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<'a> RenderContext<'a> {
gl: &'a mut gl::Gl,
size: ISize,
) -> Self {
RenderContext {
Self {
gl,
size,
}
Expand Down Expand Up @@ -67,7 +67,7 @@ impl<'a> PrerollContext<'a> {
texture: TextureId,
size: ISize,
) -> Self {
PrerollContext {
Self {
pixel_ratio,
pipeline,
gl,
Expand Down Expand Up @@ -150,7 +150,7 @@ impl Texture {
gl::BindFramebuffer(gl::FRAMEBUFFER, frame_buffer);
gl::FramebufferTexture2D(gl::FRAMEBUFFER, gl::COLOR_ATTACHMENT0, gl::TEXTURE_2D, texture, 0);
}
Texture {
Self {
gl,
gl_context,
frame_buffer,
Expand Down
Loading