我正在尝试实现一个读取命令行参数的函数,并将它们与硬编码的字符串文字进行比较.
当我与一个if陈述进行比较时,它就像一个魅力:
fn main() {
let s = String::from("holla!");
if s == "holla!" {
println!("it worked!");
}
}
Run Code Online (Sandbox Code Playgroud)
但是使用一个match声明(我想会更优雅):
fn main() {
let s = String::from("holla!");
match s {
"holla!" => println!("it worked!"),
_ => println!("nothing"),
}
}
Run Code Online (Sandbox Code Playgroud)
我一直从编译器得到一个错误,String但是a &static str被发现:
error[E0308]: mismatched types
--> src/main.rs:5:9
|
5 | "holla!" => println!("it worked!"),
| ^^^^^^^^ expected struct `std::string::String`, found reference
|
= note: expected type `std::string::String`
found type `&'static str`
Run Code Online (Sandbox Code Playgroud)
我已经看到如何在Rust中匹配字符串与字符串文字?所以我知道如何解决它,但我想知道 …
我正在尝试学习如何使用three jsReact。为此,我正在使用@react-three/fiber和@react-three/drei。
chriscourses 的这个项目是我用来学习三个 js 的项目,我希望用它来学习使用 Threejs 和 React。
下面的代码应该显示从给定坐标中萌芽的方框,但目前它们都向一个方向倾斜。使用lookat应该可以解决问题,但是我不知道如何lookat在@react-three/fiber/中使用@react-three/drei。
import React, { FC, useRef } from 'react';
import { Box as NativeBox } from '@react-three/drei'
import { Vector3 } from 'three';
import { useFrame } from '@react-three/fiber';
type Props = {
country: any,
}
const lookAtCubePosition = new Vector3(0, 0, 0)
const Box: FC<Props> = (props) => {
const mesh = useRef()
const { …Run Code Online (Sandbox Code Playgroud) 我正在将 apache 2.4 (docker) 设置为反向代理,以将不同的子域分发到不同的 docker 服务。我使用该指令将 http 请求重定向到 https Redirect。然而,一个特定的 URL 路径(域后面的部分)不应被重定向为 https,而应与来自特定目录的文件一起提供。我试图使用该Alias指令来完成此操作,但这不起作用。
我假设它Redirect会覆盖Alias. 真的吗?如果是这样的话,我该如何实现我的目标呢?
<VirtualHost *:80>
ServerName service.example.com
Alias /exception/ /var/www/exception
Redirect permanent / https://service.example.com/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
我预计这会起作用,但事实并非如此。