gpt4 book ai didi

curl - rust-slack 运行时错误 : index out of bounds: the len is 0 but the index is 0

转载 作者:行者123 更新时间:2023-11-29 08:33:25 25 4
gpt4 key购买 nike

我正在使用 rust-slack我遇到了一个运行时错误,这对于像我这样的初学者来说很难理解:

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', ../src/libcollections/vec.rs:1265
stack backtrace:
1: 0x55c042e567e9 - std::sys::backtrace::tracing::imp::write::h00e948915d1e4c72
2: 0x55c042e5d9fc - std::panicking::default_hook::_{{closure}}::h7b8a142818383fb8
3: 0x55c042e5cc49 - std::panicking::default_hook::h41cf296f654245d7
4: 0x55c042e5d338 - std::panicking::rust_panic_with_hook::h4cbd7ca63ce1aee9
5: 0x55c042e5d192 - std::panicking::begin_panic::h93672d0313d5e8e9
6: 0x55c042e5d100 - std::panicking::begin_panic_fmt::hd0daa02942245d81
7: 0x55c042e5d081 - rust_begin_unwind
8: 0x55c042e936df - core::panicking::panic_fmt::hbfc935564d134c1b
9: 0x55c042e93683 - core::panicking::panic_bounds_check::h08d619adcd972898
10: 0x55c042e1f3db - curl::easy::Easy::cvt::h8b0cee78a8555d56
11: 0x55c042e1f1fd - curl::easy::Easy::setopt_path::h97000cc95ffaf29e
12: 0x55c042e20e05 - curl::easy::default_configure::h81b9c3a40aadad76
13: 0x55c042e1e715 - curl::easy::Easy::new::h6256decf6c19f143
14: 0x55c042db16e4 - slack_hook::slack::Slack::send::h14b50e23bd1ee165
15: 0x55c042dab5af - deployer::main::had2f8b13f079aa74
16: 0x55c042e654e6 - __rust_maybe_catch_panic
17: 0x55c042e5c3c2 - std::rt::lang_start::h53bf99b0829cc03c
18: 0x7f176846682f - __libc_start_main
19: 0x55c042da5e98 - _start
20: 0x0 - <unknown>
  • 它可以在 macOS 上编译和运行(没有 panic )。
  • 它在几乎全新的 Ubuntu 16.04 上编译但失败(参见上面的错误)。

我的应用程序中有一些 println! 跟踪,所以我知道它在哪里崩溃,回溯的第 20 行似乎也说它在这里。具有讽刺意味的是,该函数名为 success,并且是一个长脚本的最后一步:

fn success()  {
let slack = Slack::new("https://hooks.slack.com/MY_HOOK_URL").unwrap();
let p = PayloadBuilder::new()
.text("Deployment success.")
.channel("#app-notifier")
.username("Deploy Bot")
.icon_emoji(":tropical_drink:")
.build()
.unwrap();

let res = slack.send(&p);
match res {
Ok(()) => println!("Success msg sent."),
Err(x) => println!("<!> Success error ^^: {:?}",x)
}
}

Slack URL 在我的本地机器上有效。如何自己解决这个特殊情况?我只需要一些线索。

最佳答案

这是 curl-rust 中的一个问题。固定在 this issue .我只需要运行 cargo update,然后重建,现在一切正常。

感谢 Lukas Kalbertodt、Alex Crichton 和 rust-slack 的作者的帮助。

关于curl - rust-slack 运行时错误 : index out of bounds: the len is 0 but the index is 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40021037/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com