我是Docker的新手.我按照Docker Compose的"入门"教程中描述的步骤操作:
docker-compose up命令我得到以下错误:
ERROR: for web Cannot create container for service web: Invalid bind mount spec "D:\\Projects\\composetest:/code:rw": Invalid volume specification: 'D:\Projects\composetest:/code:rw'
[31mERROR[0m: Encountered errors while bringing up the project.
Run Code Online (Sandbox Code Playgroud)
泊坞窗,compose.yml:
version: '2'
services:
web:
build: .
ports:
- "5000:5000"
volumes:
- .:/code:rw
redis:
image: "redis:alpine"
Run Code Online (Sandbox Code Playgroud)
项目结构:
D:\Projects\composetest
??? app.py
??? docker-compose.yml
??? Dockerfile
??? requirements.txt
Run Code Online (Sandbox Code Playgroud)
我的配置:
为什么会这样?有一些解决方法吗?
探索angular-cli最近发布的Angular2的RC1我遇到了一个奇怪的问题:node-sass在sass插件中,在包名称之前angular-cli没有解析~抛出以下错误:
Error: File to import not found or unreadable: ~@angular2-material/core/style/theme-functions
Run Code Online (Sandbox Code Playgroud)
它在编译以下代码时发生:
@import "~@angular2-material/core/style/theme-functions";
Run Code Online (Sandbox Code Playgroud)
如果我删除波浪号,一切都会好的.这是正确的行为,还是有道路可以node-sass理解~?
PS我使用WebStorm,它也喜欢使用它~.如果省略波浪号,则会导致解析路径无法解决.经过一些谷歌搜索后,我发现使用没有代字号的代码是遗留的,~应该用作最佳实践.这样对吗?
我需要获取宏重复元素的索引才能编写下一个代码:
struct A {
data: [i32; 3]
}
macro_rules! tst {
( $( $n:ident ),* ) => {
impl A {
$(
fn $n(self) -> i32 {
self.data[?] // here I need the index
}
),*
}
}
}
Run Code Online (Sandbox Code Playgroud)
我知道一种方法:告诉用户手动编写索引:
( $( $i:ident => $n:ident ),* )
Run Code Online (Sandbox Code Playgroud)
但是,有没有一种更优雅的方式不需要用户采取行动呢?
I try to write typescript functions in the style that is most close to functional. For simple functions I can write:
type A = (value: number) => string;
const a: A = value => value.toString();
Run Code Online (Sandbox Code Playgroud)
But what can I do with generic types? How can I type in that simple way following function?
function a<T>(value: T): T {
return value;
}
Run Code Online (Sandbox Code Playgroud)
If I try to simply add a generic type, it gives nothing:
type A = <T>(value: T) => T; …Run Code Online (Sandbox Code Playgroud) 我想写一个像这样的宏:
macro_rules! a {
( $n:ident, $t:ty ) => {
struct $n {
x: $t
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是$t应该实现Add,Sub和Mul特征.如何在编译时检查它?
我在Rust中创建简单的矩阵实现.我需要迭代矩阵,除了值之外还得到坐标:
for (i, j, elem) in matrix.iter().enumerate() {
...
}
Run Code Online (Sandbox Code Playgroud)
据我所见,Iterator::enumerate是预先定义的,我无法使用能够返回的自定义实现覆盖它(usize, usize, &T).有没有办法实现自定义enumerate()方法?
我想在函数外部生成代码时在宏中设置编译时条件.我需要这样的东西:
macro_rules! cond {
( $cond_el:expr ) => {
#[if $cond_el == "i32"]
struct A {
x: i32
}
#[else]
struct A {
x: f64
}
}
}
cond!("i32");
cond!("f64");
fn main() {}
Run Code Online (Sandbox Code Playgroud)
或者类似的东西:
macro_rules! cond {
( $cond_el:expr ) => {
match $cond_el {
"i32" => {
struct A {
x: i32
}
}
_ => {
struct A {
x: f64
}
}
}
}
}
cond!("i32");
cond!("f64");
fn main() {}
Run Code Online (Sandbox Code Playgroud)
是否可以使用当前的Rust宏状态?