Skip to content

Commit

Permalink
Merge branch 'iced-rs:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
GyulyVGC authored Feb 2, 2023
2 parents 376421d + 98a7173 commit d1570cf
Show file tree
Hide file tree
Showing 48 changed files with 1,087 additions and 135 deletions.
5 changes: 5 additions & 0 deletions core/src/vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ impl<T> Vector<T> {
}
}

impl Vector {
/// The zero [`Vector`].
pub const ZERO: Self = Self::new(0.0, 0.0);
}

impl<T> std::ops::Add for Vector<T>
where
T: std::ops::Add<Output = T>,
Expand Down
2 changes: 1 addition & 1 deletion examples/download_progress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ impl Download {
.into()
}
State::Downloading { .. } => {
text(format!("Downloading... {:.2}%", current_progress)).into()
text(format!("Downloading... {current_progress:.2}%")).into()
}
State::Errored => column![
"Something went wrong :(",
Expand Down
2 changes: 1 addition & 1 deletion examples/events/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Application for Events {
let events = Column::with_children(
self.last
.iter()
.map(|event| text(format!("{:?}", event)).size(40))
.map(|event| text(format!("{event:?}")).size(40))
.map(Element::from)
.collect(),
);
Expand Down
2 changes: 1 addition & 1 deletion examples/game_of_life/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn view_controls<'a>(

let speed_controls = row![
slider(1.0..=1000.0, speed as f32, Message::SpeedChanged),
text(format!("x{}", speed)).size(16),
text(format!("x{speed}")).size(16),
]
.width(Length::Fill)
.align_items(Alignment::Center)
Expand Down
2 changes: 1 addition & 1 deletion examples/integration_opengl/src/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Program for Controls {
)
.push(sliders)
.push(
Text::new(format!("{:?}", background_color))
Text::new(format!("{background_color:?}"))
.size(14)
.style(Color::WHITE),
),
Expand Down
2 changes: 1 addition & 1 deletion examples/integration_opengl/src/scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ impl Scene {
.expect("Cannot create shader");
gl.shader_source(
shader,
&format!("{}\n{}", shader_version, shader_source),
&format!("{shader_version}\n{shader_source}"),
);
gl.compile_shader(shader);
if !gl.get_shader_compile_status(shader) {
Expand Down
2 changes: 1 addition & 1 deletion examples/integration_wgpu/src/controls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Program for Controls {
)
.push(sliders)
.push(
Text::new(format!("{:?}", background_color))
Text::new(format!("{background_color:?}"))
.size(14)
.style(Color::WHITE),
)
Expand Down
2 changes: 1 addition & 1 deletion examples/integration_wgpu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub fn main() {
}
Err(error) => match error {
wgpu::SurfaceError::OutOfMemory => {
panic!("Swapchain error: {}. Rendering cannot continue.", error)
panic!("Swapchain error: {error}. Rendering cannot continue.")
}
_ => {
// Try rendering again next frame.
Expand Down
8 changes: 3 additions & 5 deletions examples/pokedex/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl Application for Pokedex {
Pokedex::Errored { .. } => "Whoops!",
};

format!("{} - Pokédex", subtitle)
format!("{subtitle} - Pokédex")
}

fn update(&mut self, message: Message) -> Command<Message> {
Expand Down Expand Up @@ -157,8 +157,7 @@ impl Pokemon {
};

let fetch_entry = async {
let url =
format!("https://pokeapi.co/api/v2/pokemon-species/{}", id);
let url = format!("https://pokeapi.co/api/v2/pokemon-species/{id}");

reqwest::get(&url).await?.json().await
};
Expand Down Expand Up @@ -187,8 +186,7 @@ impl Pokemon {

async fn fetch_image(id: u16) -> Result<image::Handle, reqwest::Error> {
let url = format!(
"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{}.png",
id
"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/{id}.png"
);

#[cfg(not(target_arch = "wasm32"))]
Expand Down
2 changes: 1 addition & 1 deletion examples/styling/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Sandbox for Styling {
column![text("Choose a theme:")].spacing(10),
|column, theme| {
column.push(radio(
format!("{:?}", theme),
format!("{theme:?}"),
*theme,
Some(match self.theme {
Theme::Light => ThemeType::Light,
Expand Down
5 changes: 2 additions & 3 deletions examples/system_information/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ impl Application for Example {
{
let memory_readable = ByteSize::kb(memory_used).to_string();

format!("{} kb ({})", memory_used, memory_readable)
format!("{memory_used} kb ({memory_readable})")
} else {
String::from("None")
};

let memory_used =
text(format!("Memory (used): {}", memory_text));
let memory_used = text(format!("Memory (used): {memory_text}"));

let graphics_adapter = text(format!(
"Graphics adapter: {}",
Expand Down
10 changes: 10 additions & 0 deletions examples/toast/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[package]
name = "toast"
version = "0.1.0"
authors = ["tarkah <admin@tarkah.dev>"]
edition = "2021"
publish = false

[dependencies]
iced = { path = "../..", features = [] }
iced_native = { path = "../../native" }
Loading

0 comments on commit d1570cf

Please sign in to comment.