Skip to content

Commit bd30e88

Browse files
committed
Remove unnecessary cfg conditionals for Config and pass ::default()
1 parent fdc9aee commit bd30e88

File tree

6 files changed

+9
-16
lines changed

6 files changed

+9
-16
lines changed

crates/processing_pyo3/src/graphics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl Graphics {
4444

4545
let mut config = Config::new();
4646
config.set(ConfigKey::AssetRootPath, asset_path.to_string());
47-
init(Some(config)).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
47+
init(config).map_err(|e| PyRuntimeError::new_err(format!("{e}")))?;
4848

4949
let surface = glfw_ctx
5050
.create_surface(width, height, 1.0)

crates/processing_render/src/lib.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ use std::{cell::RefCell, num::NonZero, path::PathBuf, sync::OnceLock};
99

1010
use config::*;
1111

12-
#[cfg(feature = "python")]
13-
use bevy::asset::io::AssetSourceBuilder;
1412
#[cfg(not(target_arch = "wasm32"))]
1513
use bevy::log::tracing_subscriber;
1614
use bevy::{
1715
app::{App, AppExit},
18-
asset::AssetEventSystems,
16+
asset::{AssetEventSystems, io::AssetSourceBuilder},
1917
prelude::*,
2018
render::render_resource::{Extent3d, TextureFormat},
2119
};
@@ -207,7 +205,7 @@ pub fn surface_resize(graphics_entity: Entity, width: u32, height: u32) -> error
207205
})
208206
}
209207

210-
fn create_app(_config: Config) -> App {
208+
fn create_app(config: Config) -> App {
211209
let mut app = App::new();
212210

213211
#[cfg(not(target_arch = "wasm32"))]
@@ -232,9 +230,7 @@ fn create_app(_config: Config) -> App {
232230
..default()
233231
});
234232

235-
#[cfg(feature = "python")]
236-
{
237-
let asset_path = _config.get(ConfigKey::AssetRootPath).unwrap();
233+
if let Some(asset_path) = config.get(ConfigKey::AssetRootPath) {
238234
app.register_asset_source(
239235
"assets_directory",
240236
AssetSourceBuilder::platform_default(asset_path, None),
@@ -271,11 +267,8 @@ fn set_app(app: App) {
271267

272268
/// Initialize the app, if not already initialized. Must be called from the main thread and cannot
273269
/// be called concurrently from multiple threads.
274-
/// asset_path is Optional because only python needs to use it.
275270
#[cfg(not(target_arch = "wasm32"))]
276-
pub fn init(config: Option<Config>) -> error::Result<()> {
277-
let config = config.unwrap_or_default();
278-
271+
pub fn init(config: Config) -> error::Result<()> {
279272
setup_tracing()?;
280273
if is_already_init()? {
281274
return Ok(());

examples/background_image.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919

2020
fn sketch() -> error::Result<()> {
2121
let mut glfw_ctx = GlfwContext::new(400, 400)?;
22-
init(None)?;
22+
init(Config::default())?;
2323

2424
let width = 400;
2525
let height = 400;

examples/rectangle.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919

2020
fn sketch() -> error::Result<()> {
2121
let mut glfw_ctx = GlfwContext::new(400, 400)?;
22-
init(None)?;
22+
init(Config::default())?;
2323

2424
let width = 400;
2525
let height = 400;

examples/transforms.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn main() {
1313

1414
fn sketch() -> error::Result<()> {
1515
let mut glfw_ctx = GlfwContext::new(400, 400)?;
16-
init(None)?;
16+
init(Config::default())?;
1717

1818
let surface = glfw_ctx.create_surface(400, 400, 1.0)?;
1919
let graphics = graphics_create(surface, 400, 400)?;

examples/update_pixels.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn main() {
1919

2020
fn sketch() -> error::Result<()> {
2121
let mut glfw_ctx = GlfwContext::new(100, 100)?;
22-
init(None)?;
22+
init(Config::default())?;
2323

2424
let width = 100;
2525
let height = 100;

0 commit comments

Comments
 (0)