我更新了我的工具链设置以使用建议的默认值:
如何解决此问题并使 CLion 能够调试 Rust 代码?
我做了一些搜索,但没有找到一个简单的答案(至少我可以很容易理解)。
任何帮助将不胜感激。
我正在尝试使用Chart.js 3.3.2显示一些具有等距 x 日期轴的折线图。就像他们在这里给出的例子一样。
我无法让此示例的简单版本正常工作(请参见下面的代码片段),因为它输出错误:
错误:未实现此方法:检查是否提供了完整的日期适配器。
我没有尝试实现整个示例,因为它依赖于外部定义的函数和值。
我很久以前就问过类似的问题(Chart.js 创建使用日期的折线图),但是重新阅读了那里的答案,它对我没有帮助(值得注意的是这里的大多数答案也集中在 Chart.js 2 而不是 3)。
我非常感谢这里的任何帮助(我发现这里的文档很难理解)。
const data = {
labels: [
new Date(86400000), // Day 1
new Date(2*86400000), // Day 2
new Date(3*86400000), // Day 3
new Date(4*86400000), // Day 4
new Date(6*86400000), // Day 6
new Date(7*86400000), // Day 7
new Date(13*86400000) // Day 13
],
datasets: [{
label: 'My First dataset',
data: [1,3,4,5,6,7,8]
}]
};
const config = {
type: 'line',
data: data, …Run Code Online (Sandbox Code Playgroud)有没有办法使用 Rust 而不是简单地附加来覆盖控制台输出?
一个例子是打印进度的百分比;我宁愿覆盖该行也不愿打印新行。
我似乎无法让Chart.js使用日期.我尝试了很多不同的方法:
let examChart = document.getElementById("examChart").getContext("2d");
let examLineChart = new Chart(examChart, {
type: "line",
data: [
{ t: new Date("2015-3-15 13:3"), y: 12 },
{ t: new Date("2015-3-25 13:2"), y: 21 },
{ t: new Date("2015-4-25 14:12"), y: 32 }
],
options: {
label: "placeholder"
}
});
Run Code Online (Sandbox Code Playgroud)
和:
let examChart = document.getElementById("examChart").getContext("2d");
let examLineChart = new Chart(examChart, {
type: "line",
data: [
{ t: "2015-3-15 13:3", y: 12 },
{ t: "2015-3-25 13:2", y: 21 },
{ t: "2015-4-25 14:12", y: …Run Code Online (Sandbox Code Playgroud) 我已经完全按照教程进行了操作,但似乎无法正常工作。本教程位于以下JavaFX and Intellij Non-modular from IDE部分中:https : //openjfx.io/openjfx-docs/#install-java
这是尝试运行默认的Intellij Idea JavaFX项目时收到的错误消息:
"C:\Program Files\Java\jdk-11.0.1\bin\java.exe" --module-path %PATH_TO_FX% --add-modules=javafx.controls,javafx.fxml --add-modules javafx.base,javafx.graphics --add-reads javafx.base=ALL-UNNAMED --add-reads javafx.graphics=ALL-UNNAMED "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA 2018.3\lib\idea_rt.jar=53491:C:\Program Files\JetBrains\IntelliJ IDEA 2018.3\bin" -Dfile.encoding=UTF-8 -classpath "C:\Users\jonat\IdeaProjects\Tawe-Lib FX\out\production\Tawe-Lib FX;C:\Program Files\Java\javafx-sdk-11.0.1\lib\src.zip;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx-swt.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.web.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.base.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.fxml.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.media.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.swing.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.controls.jar;C:\Program Files\Java\javafx-sdk-11.0.1\lib\javafx.graphics.jar" sample.Main
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found
Process finished with exit code 1
Run Code Online (Sandbox Code Playgroud)
正如我在侧边栏javafx.base下方看到的那样,这对我来说毫无意义lib:

通往jdk-11.0.1和的路径javafx-sdk-11.0.1:
C:\ Program Files \ Java …
在我的应用程序中,一个方法一旦启动就运行得很快,但在接近完成时性能开始不断下降,这似乎与工作量(每个线程必须执行的函数的迭代次数)无关。一旦接近尾声,与之前相比,它的速度会减慢到令人难以置信的慢(值得注意的是,这不仅是由于剩余未完成的线程较少,似乎每个线程都变慢了)。
我无法弄清楚为什么会发生这种情况,所以我在问。我究竟做错了什么?
问题的幻灯片
值得注意的是,CPU 温度始终保持较低。
这个阶段随着设置的工作量而变化,更多的工作会产生更好的外观,所有线程始终接近 100%。不过,在这一刻,这看起来不错。
在这里我们看到了之前的持续表现,
在这里,我们看到它开始退化。我不知道为什么会发生这种情况。
经过一段时间的混乱之后,大多数线程完成了它们的工作,其余线程继续运行,此时虽然看起来它们已达到 100%,但实际上它们执行剩余工作量的速度非常缓慢。我不明白为什么会发生这种情况。
我编写了一个多线程random_search(文档链接)函数进行优化。此函数的大部分复杂性来自打印数据在线程之间传递数据,这支持提供显示进度的输出,例如:
2300
565 (24.57%) 00:00:11 / 00:00:47 [25.600657363049734] { [563.0ns, 561.3ms, 125.0ns, 110.0ns] [2.0µs, 361.8ms, 374.0ns, 405.0ns] [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] }
Run Code Online (Sandbox Code Playgroud)
我一直在尝试使用此输出来找出出了什么问题,但我不知道。
此输出描述:
2300。565。00:00:11(mm:ss:ms)。00:00:47( mm:ss:ms)。[25.600657363049734]。我正在尝试编写一种数据结构,使其在不同维度上具有通用性。
\n开头是:
\n/// A field of adjacent sections in a given dimensionality.\n/// With 1, you have `|left|center|right|`.\n/// With 2 dimensions you have:\n/// ```\n/// up_left\xe2\x94\x82 up\xe2\x94\x82up_right\n/// \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n/// left\xe2\x94\x82center\xe2\x94\x82right\n/// \xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\xbc\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\xe2\x94\x80\n/// down_left\xe2\x94\x82 down\xe2\x94\x82down_right\n/// ```\n/// Etc.\n#[derive(Debug)]\nstruct Adjacents<T, const D: u32>([T; size(D)])\n\nconst fn size(d: u32) -> usize { 3u32.pow(d) as usize }\nRun Code Online (Sandbox Code Playgroud)\n当尝试编写如下实现时:
\nimpl<T> Adjacents<T,1u32> { /*...*/ }\nRun Code Online (Sandbox Code Playgroud)\n我遇到严重警告(在少数情况下):
\nwarning: cannot use constants which depend on generic parameters in types\n --> src/main.rs:26:9\n |\n26 | impl<T> Adjacents<T,1u32> {\n …Run Code Online (Sandbox Code Playgroud) 我有一个程序属性宏,给定一个函数对每个二进制表达式进行操作,例如let a = b + c;并根据它返回另一个表达式。根据类型进行操作,需要知道、、+的类型。abc
有没有办法在编译时获取变量的推断类型?
(就像 rust-analysisr 可能会显示推断的类型一样,我可以在宏中获取这些类型吗?)
为了在 Rust 游乐场中更简洁地说明我的方法,我们可以使用声明性宏来调用给定变量上的函数,该函数的细节基于给定变量的类型。
我在 Rust 游乐场中最接近我想要的功能:
macro_rules! SomeMacro {
($x:expr) => {{
$x.some_function(3.)
}};
}
trait SomeTrait {
fn some_function(&self,x:f32) -> f32;
}
impl SomeTrait for u32 {
fn some_function(&self,x:f32) -> f32 {
x * 3.
}
}
fn main() {
let a = 3u32;
let b = SomeMacro!(a);
assert_eq!(b,9.);
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能让事情像这样工作:
fn some_function<u32>(x:f32) -> f32 {
3. * x …Run Code Online (Sandbox Code Playgroud) 我很大程度上相信这个错误是由于我调用的对象不包含该.populate函数造成的,尽管我不知道如何更改它以使其工作。
首先,这是完整的错误。
TypeError: exam[0].modules[u].topics[i].populate(...).exec is not a function
at /home/ubuntu/workspace/tests/app.js:425:84
at Query.Model.$wrapCallback (/home/ubuntu/workspace/tests/node_modules/mongoose/lib/model.js:3336:16)
at /home/ubuntu/workspace/tests/node_modules/mongoose/node_modules/kareem/index.js:259:21
at /home/ubuntu/workspace/tests/node_modules/mongoose/node_modules/kareem/index.js:127:16
at nextTickCallbackWith0Args (node.js:420:9)
at process._tickCallback (node.js:349:13)
Process exited with code: 1
Run Code Online (Sandbox Code Playgroud)
我指的具体行是exam[0].modules[u].topics[i].populate("questions").exec(function(err,quests)另一行,我认为这里非常重要,这是examBoard.find({name:req.body.examBoardName},function(err,exam)返回exam不包含该.populate函数的行。
我认为这很大程度上是由于我缺乏经验,而不是逻辑错误,但我不确定。
这是包含错误的代码部分。
app.post("/test",function(req,res)
{
console.log("\n\n\n\n")
var time = req.body.time;
var topicName = [req.body.topic1,req.body.topic2,req.body.topic3,req.body.topic4,req.body.topic5];
var topicsArray = [];
examBoard.find({name:req.body.examBoardName},function(err,exam)
{
if(err)
{
console.log(err);
}
else
{
for(var u=0;u<exam[0].modules.length;u++)
{
console.log("exam[0].modules[u]:\n"+exam[0].modules[u]);
console.log("req.body.moduleName:\n"+req.body.moduleName);
if(exam[0].modules[u].name==req.body.moduleName)
{
console.log("topicName[]:\n"+topicName[0]+"\n"+topicName[1]+"\n"+topicName[2]+"\n"+topicName[3]+"\n"+topicName[4]);
for(var i=0;i<exam[0].modules[u].topics.length;i++)
{
console.log("exam[0].modules[u].topics[i].name:\n"+exam[0].modules[u].topics[i].name);
for(var t=0;t<topicName.length;t++)
{
if(exam[0].modules[u].topics[i].name==topicName[t]) …Run Code Online (Sandbox Code Playgroud) 我第一次遇到这样的错误,如果我没有注意到任何重要的因素,请原谅我。我在运行代码时遇到的完整错误是:
(node:10812) [DEP0062] DeprecationWarning: `node --inspect --debug-brk` is deprecated. Please use `node --inspect-brk` instead.
Run Code Online (Sandbox Code Playgroud)
如图所示:
它还突出显示了这行代码:
return new Script(code, options);
Run Code Online (Sandbox Code Playgroud)
如图所示:
这是我正在运行的 node.js 版本,如 nvm 所示。
C:\Users\jonat>nvm install latest
Version 8.4.0 is already installed.
Run Code Online (Sandbox Code Playgroud)
我昨天运行了 VS 安装程序,所以它是最新的。
这些是我正在使用的模块:
const express = require("express"),
mongoose = require("mongoose"),
passport = require("passport"),
bodyParser = require("body-parser"),
LocalStrategy = require("passport-local"),
passportLocalMongoose = require("passport-local-mongoose"),
math = require("mathjs");
Run Code Online (Sandbox Code Playgroud)
它们是通过 npm 安装的,我最近在.npm update这里运行,它们显示在继承人的文件目录中:
此处更改了各种设置,并设置了将进一步使用的变量:
const app = express();
const uri = 'mongodb://localhost/MathsWebsite',
options = { useMongoClient: true …Run Code Online (Sandbox Code Playgroud)