#![warn(clippy::all, rust_2018_idioms)]#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]// hide console window on Windows in release// When compiling natively:#[cfg(not(target_arch = "wasm32"))]fnmain()->eframe::Result<()>{env_logger::init();// Log to stderr (if you run with `RUST_LOG=debug`).let native_options =eframe::NativeOptions::default();eframe::run_native("demo app",// `eframe template` to `demo app`
native_options,Box::new(|cc|Box::new(demo_app::TemplateApp::new(cc))),// `eframe_template::TemplateApp` to `demo_app::TemplateApp`)}// When compiling to web using trunk:#[cfg(target_arch = "wasm32")]fnmain(){// Redirect `log` message to `console.log` and friends:eframe::WebLogger::init(log::LevelFilter::Debug).ok();let web_options =eframe::WebOptions::default();wasm_bindgen_futures::spawn_local(async{eframe::WebRunner::new().start("the_canvas_id",// hardcode it
web_options,Box::new(|cc|Box::new(demo_app::TemplateApp::new(cc))),// `eframe_template::TemplateApp` to `demo_app::TemplateApp`).await.expect("failed to start eframe");});}
var cacheName ='egui-template-pwa';var filesToCache =['./','./index.html','./demo_app.js','./demo_app_bg.wasm',];/* Start the service worker and cache all of the app's content */
self.addEventListener('install',function(e){
e.waitUntil(
caches.open(cacheName).then(function(cache){return cache.addAll(filesToCache);}));});/* Serve cached content when offline */
self.addEventListener('fetch',function(e){
e.respondWith(
caches.match(e.request).then(function(response){return response ||fetch(e.request);}));});
文章目录 Ch4. 随机变量的数字特征1. 数学期望E(X)(1)数学期望的概念1.离散型①一维离散型随机变量X的数学期望: E X EX EX②一维离散型随机变量的函数的期望: E [ g ( X ) ] E[g(X)] E[g(X)]③二维离散型随机变量的函数的期望: E [ g ( X , …