我跑npm run start,服务器运行正常.当我尝试查看客户端时localhost,服务器返回错误:GET/500 62.700 ms - 2028错误:无法在视图目录"/ views"中查找视图"错误"
只使用源文件时,应用程序运行正常.从webpack bundle运行应用程序时发生此错误.
导致此错误的源文件和捆绑文件之间有什么区别?
webpack.config.js
var webpack = require('webpack');
var path = require('path');
var nodeModules = {};
fs.readdirSync('node_modules')
.filter(function(x) {
return ['.bin'].indexOf(x) === -1;
})
.forEach(function(mod) {
nodeModules[mod] = 'commonjs ' + mod;
});
module.exports = [
{
entry: {
'app_bundle': './server.js'
},
target: 'node',
query: {
cacheDirectory: true,
presets: ['es2015']
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/
} …Run Code Online (Sandbox Code Playgroud) 将ref-struct实例嵌套在另一个实例中,嵌套对象的其中一个属性在手动垃圾回收时会损坏.
请参阅此最小代码复制:https://github.com/hunterlester/minimum-ref-struct-corruption
请注意日志输出的第3行,其值name未损坏:
Running garbage collection...
authGranted object afte gc: { name: '?_n9a\u0002', 'ref.buffer': <Buffer@0x00000261396F3910 18 86 6c 39 61 02 00 00> }
Unnested access container entry after gc: { name: 'apps/net.maidsafe.examples.mailtutorial', 'ref.buffer': <Buffer@0x00000261396F3B10 60 68 6e 39 61 02 00 00> }
Globally assigned values after gc: apps/net.maidsafe.examples.mailtutorial _publicNames
Run Code Online (Sandbox Code Playgroud) 我想生成 6 个随机数,将它们推送到一个向量上,然后使用rustc_serialize该向量将该向量编码为 NodeJS使用的 JSON 字符串。
extern crate rand;
extern crate rustc_serialize;
use rand::{OsRng, Rng};
use rustc_serialize::json::{self, Json, ToJson};
#[no_mangle]
pub extern "C" fn generate() -> String {
let choices: [u8; 6] = [1, 2, 3, 4, 5, 6];
let mut rand_vec: Vec<u8> = Vec::new();
let mut rng = match OsRng::new() {
Ok(t) => t,
Err(e) => panic!("Failed to create OsRng!, {}", e),
};
for _ in 0..5 {
rand_vec.push(*rng.choose(&choices).unwrap());
}
json::encode(&rand_vec).unwrap()
}
Run Code Online (Sandbox Code Playgroud)
这段代码被编译为一个库generate_6_rand.dll。我有一个单独的二进制文件,用于测试此代码。
如果我跑
println!("{:?}", …Run Code Online (Sandbox Code Playgroud) 存储库
https://github.com/hunterlester/rusty_arcade
版本
Rust:1.7.0
sdl2:0.16.1
sdl2_image:0.16.0
错误
src/views/mod.rs:88:13: 93:23 error: mismatched types:
expected `core::option::Option<sdl2::rect::Rect>`,
found `sdl2::rect::Rect`
(expected enum `core::option::Option`,
found struct `sdl2::rect::Rect`) [E0308]
src/views/mod.rs:88 Rectangle {
src/views/mod.rs:89 x: 0.0,
src/views/mod.rs:90 y: 0.0,
src/views/mod.rs:91 w: self.player.rect.w,
src/views/mod.rs:92 h: self.player.rect.h,
src/views/mod.rs:93 }.to_sdl(),
src/views/mod.rs:88:13: 93:23 help: run `rustc --explain E0308` to see a detailed explanation
src/views/mod.rs:94:13: 94:38 error: mismatched types:
expected `core::option::Option<sdl2::rect::Rect>`,
found `sdl2::rect::Rect`
(expected enum `core::option::Option`,
found struct `sdl2::rect::Rect`) [E0308]
src/views/mod.rs:94 self.player.rect.to_sdl()
Run Code Online (Sandbox Code Playgroud)
跟踪
指定文件的第93和94行.
phi.renderer.copy(&mut self.player.tex,
Rectangle {
x: 0.0,
y: 0.0, …Run Code Online (Sandbox Code Playgroud) 我正在学习如何使用https://intermezzos.github.io构建基本的OS内核
我已经创建了.iso文件,并且正在qemu-system-x86_64 -cdrom os.iso
运行我按Enter键的地方,QEMU运行带有以下输出的窗口:
Booting from Floppy...
Boot failed: could not read the boot disk
Booting from DVD/CD...
Boot failed: Could not read from CDROM (code 0004)
Booting from ROM...
iPXE (PCI 00:03.0) starting execution...ok
iPXE initializing devices...ok
iPXE 1.0.0+git-20131111.c3d1e78-2ubuntu1.1 -- Open Source Network Boot Firmware
-- http://ipxe.org
Features: HTTP HTTPS iSCSI DNS TFTP AoE bzImage ELF MBOOT PXE Menu
net0: 52:54:00:12:34:56 using 82549em on PCI00:03.0 (open)
[Link:up, TX:0 TXE:0 RX:0 RXE:01]
Configuring (net0 …Run Code Online (Sandbox Code Playgroud) 我需要rustc_serialize::Decoder为我的Herdstruct 实现trait :
extern crate chrono;
extern crate rustc_serialize;
use chrono::NaiveDate;
use rustc_serialize::Decodable;
struct Herd {
id: i32,
breed: String,
name: String,
purchase_date: NaiveDate,
}
impl Decodable for Herd {
fn decode<D: Decoder>(d: &mut D) -> Result<Herd, D::Error> {
d.read_struct("Herd", 4, |d| {
let id = try!(d.read_struct_field("id", 0, |d| d.read_i32()));
let breed = try!(d.read_struct_field("breed", 1, |d| d.read_str()));
let name = try!(d.read_struct_field("name", 2, |d| d.read_str()));
let purchase_date = try!(d.read_struct_field("purchase_date", 3, |i| {
i.read_struct("NaiveDate", 1, |i| {
let …Run Code Online (Sandbox Code Playgroud)