我有一些使用info!Rust 日志箱的测试。我试过:
RUST_LOG=all cargo test -- --nocapture my_tests
Run Code Online (Sandbox Code Playgroud)
但日志根本不会出来。
但我没有初始化记录器,因为 puttinenv_logger::init();不起作用:
failed to resolve: use of undeclared crate or module `env_logger`
Run Code Online (Sandbox Code Playgroud) 有没有办法获取请求的最终URL?我知道我可以自己禁用重定向,但有没有办法获取我正在加载的当前URL?就像,如果我要求a.com并被重定向到b.com,有没有办法获得url b.com的名称?
我想轮询一个异步函数:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
some_function().await;
}
Run Code Online (Sandbox Code Playgroud)
我目前正在激活所有功能:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
some_function().await;
}
Run Code Online (Sandbox Code Playgroud)
其中哪些是必要的?
tokio = { version = "1.4.0", features = ["full"] }
Run Code Online (Sandbox Code Playgroud) 在https://github.com/sdroege/rtsp-server/blob/master/src/listener/message_socket.rs上,它确实
use crate::body::Body;
Run Code Online (Sandbox Code Playgroud)
我只能找到有关外部板条箱的信息:https ://doc.rust-lang.org/reference/items/extern-crates.html
这是什么use crate::意思?
我有以下build.gradle文件:
apply plugin:'application'
mainClassName = "MyMain"
allprojects {
sourceCompatibility = 1.7
targetCompatibility = 1.7
}
repositories {
mavenCentral()
}
dependencies {
compile 'org.jsoup:jsoup:1.8.3'
}
Run Code Online (Sandbox Code Playgroud)
因此,当我做gradle run它完美的工作,它使用jsoup等.
现在,我已经在我的Intellij Idea IDE中导入了这个项目,我创建了一个gradle构建运行/调试配置,所以当我按下绿色箭头'run'时,它正在构建应用程序,但没有运行它,所以我猜它正在执行gradle build.
我已经搜索了运行应用程序的方法,Intellij Idea说我必须创建一个新的Application run/debug配置.我做了,告诉我的主要课程在哪里,但是当我点击运行时,它会尝试制作源代码,并声称它无法找到Jsoup进行编译.
我如何模仿gradle runintellij idea的IDE?
pub async fn send_and_expect(&mut self, request: rtsp_types::Request<Body>, retrying: bool) -> std::result::Result<rtsp_types::Response<Body>, ClientActionError> {
Run Code Online (Sandbox Code Playgroud)
我得到:
pub async fn send_and_expect(&mut self, request: rtsp_types::Request<Body>, retrying: bool) -> std::result::Result<rtsp_types::Response<Body>, ClientActionError> {
Run Code Online (Sandbox Code Playgroud)
我找到了https://rust-lang.github.io/async-book/07_workarounds/04_recursion.html但它适用于不使用async.
这里应该走什么路?
我发现为什么递归异步函数需要“Rust 中的静态参数?” 我将我的功能更改为
pub fn send_and_expect(&mut self, request: rtsp_types::Request<Body>, retrying: bool)
-> Pin<Box<dyn Future <Output = std::result::Result<rtsp_types::Response<Body>, ClientActionError>>>> {
Run Code Online (Sandbox Code Playgroud)
但现在我不能await在我的函数中使用。另外,我该如何退货?
例如:
return Box::pin(Err(ClientActionError::CSeqMissing))
Run Code Online (Sandbox Code Playgroud)
行不通
更新:
根据下面的答案,我在递归调用中得到了这个:
194 | }.boxed()
| ^^^^^ future created by async block is not `Send`
|
= help: the …Run Code Online (Sandbox Code Playgroud) 我正在按照Go分析中的本教程进行操作,并按照建议进行了操作:
flag.Parse()
if *cpuprofile != "" {
f, err := os.Create(*cpuprofile)
if err != nil {
log.Fatal(err)
}
pprof.StartCPUProfile(f)
defer pprof.StopCPUProfile()
}
Run Code Online (Sandbox Code Playgroud)
然后,我从标志开始代码,-cpuprofile=myprogram.prof并创建了文件。然后,我开始了pprof tool与
go tool pprof myprogram myprogram.prof
Run Code Online (Sandbox Code Playgroud)
好吧,myprogram读取一个大的json文件并将其映射到一个大的map [string] string,所以程序中发生了很多事情,但是当我喜欢top10in时pprof,会得到:
Entering interactive mode (type "help" for commands)
(pprof) top10
profile is empty
Run Code Online (Sandbox Code Playgroud) 我正在阅读一些代码,它有一个consume函数可以让我传递我自己的函数f。
fn consume<R, F>(self, _timestamp: Instant, len: usize, f: F) -> Result<R>
where
F: FnOnce(&mut [u8]) -> Result<R>,
Run Code Online (Sandbox Code Playgroud)
我写了一些类似的代码,但像这样:
pub fn phy_receive(
&mut self,
f: &mut dyn FnMut(&[u8])
) -> u8 {
Run Code Online (Sandbox Code Playgroud)
公平地说,除了FnOncevs之外,我不知道有什么区别FnMut。使用dyn与泛型类型参数来指定此函数有什么区别?
struct State {
x: i32
}
trait A {
fn a(&mut self, b: &i32);
}
impl A for State {
fn a(&mut self, b: &i32) {
}
}
fn main() {
let mut a = State{x: 0};
a.a(&a.x);
}
Run Code Online (Sandbox Code Playgroud)
错误:
error[E0502]: cannot borrow `a` as mutable because it is also borrowed as immutable
--> src/main.rs:17:5
|
17 | a.a(&a.x);
| ^^-^----^
| | | |
| | | immutable borrow occurs here
| | immutable borrow later used by call …Run Code Online (Sandbox Code Playgroud) 我有一个完整的 Docker 映像,其中包含 Flutter SDK、Android SDK、Dart SDK 等,所有这些都安装在 $PATH 中。
我让它在 Intellij Idea 上工作,我可以单击“部署”并启动它,但后来我不知道还能做什么。
我认为 Intellij Idea 可以在这个容器中工作,所以它会找到 Dart SDK 等,并且可以工作。
如何使用 Intellij Idea 上容器中的 SDK 编译我的 Flutter 项目?以及如何使用智能感知等,一切都来自容器内的事物
rust ×6
java ×2
android ×1
containers ×1
docker ×1
flutter ×1
go ×1
gradle ×1
memory ×1
module ×1
networking ×1
okhttp ×1
okhttp3 ×1
rust-tokio ×1