cleanup + cfg-if
This commit is contained in:
@@ -27,6 +27,7 @@ eframe = { git = "https://github.com/Titaniumtown/egui", default-features = fals
|
|||||||
include-flate = { git = "https://github.com/Titaniumtown/include-flate.git" }
|
include-flate = { git = "https://github.com/Titaniumtown/include-flate.git" }
|
||||||
shadow-rs = { version = "0.9", default-features = false }
|
shadow-rs = { version = "0.9", default-features = false }
|
||||||
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
const_format = { version = "0.2.22", default-features = false, features = ["fmt"] }
|
||||||
|
cfg-if = "1.0.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = "0.9"
|
shadow-rs = "0.9"
|
||||||
|
|||||||
21
src/lib.rs
21
src/lib.rs
@@ -1,23 +1,20 @@
|
|||||||
#![allow(clippy::unused_unit)] // Fixes clippy keep complaining about wasm_bindgen
|
#![allow(clippy::unused_unit)] // Fixes clippy keep complaining about wasm_bindgen
|
||||||
#![feature(const_mut_refs)]
|
#![feature(const_mut_refs)]
|
||||||
#![feature(total_cmp)]
|
|
||||||
|
|
||||||
mod egui_app;
|
mod egui_app;
|
||||||
mod function;
|
mod function;
|
||||||
mod misc;
|
mod misc;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
cfg_if::cfg_if! {
|
||||||
use misc::log_helper;
|
if #[cfg(target_arch = "wasm32")] {
|
||||||
#[cfg(target_arch = "wasm32")]
|
use misc::log_helper;
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[global_allocator]
|
||||||
#[global_allocator]
|
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
||||||
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
|
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[wasm_bindgen]
|
||||||
#[wasm_bindgen]
|
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
||||||
pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
|
||||||
log_helper("Initializing...");
|
log_helper("Initializing...");
|
||||||
|
|
||||||
// Used in order to hook into `panic!()` to log in the browser's console
|
// Used in order to hook into `panic!()` to log in the browser's console
|
||||||
@@ -30,4 +27,6 @@ pub fn start(canvas_id: &str) -> Result<(), wasm_bindgen::JsValue> {
|
|||||||
log_helper("Starting App...");
|
log_helper("Starting App...");
|
||||||
let app = egui_app::MathApp::default();
|
let app = egui_app::MathApp::default();
|
||||||
eframe::start_web(canvas_id, Box::new(app))
|
eframe::start_web(canvas_id, Box::new(app))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#![feature(const_mut_refs)]
|
#![feature(const_mut_refs)]
|
||||||
#![feature(total_cmp)]
|
|
||||||
|
|
||||||
mod egui_app;
|
mod egui_app;
|
||||||
mod function;
|
mod function;
|
||||||
|
|||||||
Reference in New Issue
Block a user