RError.com

RError.com Logo RError.com Logo

RError.com Navigation

  • 主页

Mobile menu

Close
  • 主页
  • 系统&网络
    • 热门问题
    • 最新问题
    • 标签
  • Ubuntu
    • 热门问题
    • 最新问题
    • 标签
  • 帮助
主页 / user-208870

Антон's questions

Martin Hope
Антон
Asked: 2022-01-16 20:02:16 +0000 UTC

如何取消引用 rust-gdb 中的 Box?

  • 2

在尝试调试我的 Rust 代码时,我想知道:

如何找出它指向的数据类型Box<dyn ...>以及如何打印这些数据(结构字段)?

我打印变量 s:

(gdb) p s
$1 = core::option::Option<alloc::boxed::Box<StmtAble, alloc::alloc::Global>>::Some(izber::ir::Box<StmtAble, alloc::alloc::Global> {pointer: 0x5555555d9b70, vtable: 0x5555555d1950})
rust
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-07-03 02:30:38 +0000 UTC

unordered_map.h 中的 __detail 名称是什么?

  • 0

我决定找出哈希表是如何在我的 STL 版本中实现的。我转到文件/usr/include/c++/9/bits/unordered_map.h并在那里查看名称__detail:

namespace std _GLIBCXX_VISIBILITY(default)
{
_GLIBCXX_BEGIN_NAMESPACE_VERSION
_GLIBCXX_BEGIN_NAMESPACE_CONTAINER

  /// Base types for unordered_map.
  template<bool _Cache>
    using __umap_traits = __detail::_Hashtable_traits<_Cache, false, true>;

什么是_GLIBCXX_BEGIN_NAMESPACE_VERSION和_GLIBCXX_BEGIN_NAMESPACE_CONTAINER?文件中没有指令#include。__detail, 这是什么 ?

c++
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-06-02 21:36:19 +0000 UTC

是否可以使用匿名结构在 Rust 中实现组合?

  • 0

我正在编写一个 Rust 编译器,它记录在 Java Dragon book 中。到目前为止,我只写了一个词法分析器。有一个 Token 类,它有子 Word、Num、Real。反过来,Word 类有一个 Type 子级,它有一个 Array 子级。

我目前如何在 Rust 中实现这一点:

pub struct TokenBase {
    tag: u32,
}

pub struct WordBase {
    token: TokenBase,
    lexeme: String,
}

// ...

pub enum Word {
    Word(WordBase),
    Type(TypeBase),
}

pub enum Token {
    Token(TokenBase),
    Word(Word),
    //...
}

在 Rust 中,枚举变量的关联值可以定义为匿名结构:

pub enum Token {
    Token {
        tag: u32,
    },
//...

但是如何为后代定义结构呢?它可以做到吗?

ооп
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-05-31 00:33:55 +0000 UTC

如何从 Rust 的文本文件中逐个字符地读取?

  • 1

我需要从文本文件中逐个字符地读取,如何在没有 libc 和系统调用的 Rust 中做到这一点?

rust
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-05-10 01:20:49 +0000 UTC

为什么 Rust 不能像在 C++ 中那样在 main 之前分配内存?

  • 5

C++中有这段代码:

#include <iostream>

struct Foo {
    int * ptr;
public:
    Foo() {
        ptr = new int;
        std::cout << "Foo constructor" << std::endl;
    }
    ~Foo() {
        delete ptr;
        std::cout << "Foo destructor" << std::endl;
    }
};

auto foo = Foo();

int main() {
    std::cout << "Hello" << std::endl;
    return 0;
}

它编译和运行没有任何问题。其中,在调用 main 之前,会创建一个对象,分配内存。但是如果你在 Rust 中做这样的事情,编译器不会让你这样做:

pub static foo: Foo = Foo::new("Hello".to_string());

他不喜欢to_string()分配内存的功能。为什么 Rust 是这样设计的?什么是安全的(Rust 被定位为安全的系统编程语言)?

rust
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-01-06 23:29:13 +0000 UTC

sregex_iterator 在字符串上找不到匹配项

  • 1

我有一个字符串 - 需要使用正则表达式解析的 html 代码。我需要将页面上的所有 URL 写入 std::vector href=""。我的常规 C++ 代码不起作用。

#include <regex>
#include <iostream>
#include <string>

using std::string;
using std::regex;
using std::cout;
using std::endl;
using std::sregex_iterator;
using std::smatch;

int main()
{
    string subject("<head><title>Search engines</title></head><body><a href=\"https://yandex.ru\">Yandex</a><a href=\"https://google.com\"></a></body>");

    try {
        regex re("<\\s*A\\s+[^>]*href\\s*=\\s*\"([^\"]*)\"");
        sregex_iterator next(subject.begin(), subject.end(), re);
        sregex_iterator end;

        if (next == end)
            cout << "Oops" << endl;

        while (next != end) {
            smatch match = *next;
            cout << match.str() << endl;
            next++;
        }
    } catch (std::regex_error& e) {
        ; // Syntax error in the regular expression
    }

    return 0;
}

只有 Python'ovsky 有效。

#!/usr/bin/python3
import re

html = '<head><title>Search engines</title></head><body><a href="https://yandex.ru">Yandex</a><a href="https:/google.com"></a></body>'

title = re.findall(r'<title>(.*?)</title>', html)[0]
links = [ x[1] for x in re.findall(r'<a\s+(?:[^>]*?\s+)?href=(["\'])(.*?)\1', html)]

print (title)
print (links)

我想你可以花一周时间翻阅 Jeffrey Friedl 的正则表达式指南和 regex 库并得到你想要的结果,但 stackoverflow 并不是为了“阅读 Friedl,不要要求消化粥”之类的建议。此外,对于这样一个看似有用的问题,堆栈上没有答案可以让它发挥作用。

c++
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-05-19 23:04:09 +0000 UTC

如何使用 Django ORM 从数据库中过滤数据

  • 1

有以下型号:

class Situation(models.Model):
    lat = models.FloatField()
    lon = models.FloatField()
    hintContent = models.CharField(max_length=400)
    balloonContent = models.CharField(max_length=400)

我需要在 views.py 中获取满足条件的所有数据:( (lat - x)**2 + (lon - y)**2 < 1.05其中 x 和 y 是实数)。在这种情况下,我没有在文档中找到如何使用 ORM。

django
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-03-28 20:35:59 +0000 UTC

如果没有表单,PHP 从哪里获取表单数据?

  • 0

有以下代码:

<!DOCTYPE html>
<html>
<head>
    <title>Секретная страница</title>
</head>
<body>
<?php
    if ((!isset($_POST['name'])) || (!isset($_POST['password']))) {
?>
    <h1>Пожалуйста, войдите</h1>
    <p>Это секретная страница.</p>
    <form method="post" action="secret.php">
    <p><label for="name">Имя пользователя:</label> 
    <input type="text" name="name" id="name" size="15" /></p>
    <p><label for="password">Пароль:</label> 
    <input type="password" name="password" id="password" size="15" /></p>
    <button type="submit" name="submit">Войти</button>    
    </form>
<?php
  } else if(($_POST['name']=='user') && ($_POST['password']=='pass')) {
    echo '<h1>Вот она!</h1>
          <p>Бьемся об заклад, что вы безумно рады возможности видеть эту секретную страницу.</p>';
  } else {
    echo '<h1>Уходите!</h1>
          <p>Вы не имеете права использовать этот ресурс.</p>';
  }
?>
</body>
</html>

在浏览器中,此页面如下所示: 浏览器页面

_POST 数组中的“名称”和“密码”索引从何而来?

if ((!isset($_POST['name'])) || (!isset($_POST['password']))) {

如果我没有通过填写任何表格进入此页面?

为什么从一个 PHP 文件创建两个 HTML 页面(在输入表单数据后)?我以为那一个

php
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-01-13 00:36:01 +0000 UTC

Linux 安装不是从可引导的 USB 闪存驱动器开始

  • 1

我正在尝试通过可启动闪存驱动器在 Windows 10 旁边安装 Linux 发行版。但是,重新启动计算机后,会出现 grub 控制台,而不是提供安装 Linux。我在网络上搜索了这个问题,他们说它很可能secure boot处于启用模式,需要将其更改为禁用。但事实证明,我已经禁用了。有什么优惠?

linux
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-01-07 22:48:35 +0000 UTC

如何在 Windows 10 中为程序设置键盘快捷键

  • 1

如何设置键盘快捷键以打开谷歌浏览器、命令行等程序。在 Windows 10 中?

windows
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-12-20 23:32:55 +0000 UTC

无法创建新的 SQL Server 数据库

  • 0

我目前正在阅读 Troelsen 的书,在创建新的 SQL Server 数据库时,出现错误:在此处输入图像描述

该怎么办 ?

c#
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-07-27 16:39:38 +0000 UTC

选择 HTML 中的文本

  • 1

有一个标签(在 Python 模板中)<p>{{ event.date }} {{ event.name }}</p>。我需要使文本{{ event.date }}变灰,我该怎么做?

html
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-07-27 15:10:51 +0000 UTC

如何在 HTML 中的一行中均匀地放置文本?

  • 1

我需要在同一行上均匀分布以下数据:

'27.07.2017', 'USD: 59,91', 'Euro: 69,68', 'Brent: 50,91', 'Вы вошли как Guido'.

汇率和石油应该处于中间位置。为此,我只使用了一个<pre>没有任何样式、有几十个空格的标签。

html
  • 3 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-07-22 14:14:18 +0000 UTC

Django中如何通过session识别用户数据

  • 0

授权用户在页面上发表评论。我怎样才能实现一个视图got_comment(request)。有一个模型:

class Comment(models.Model):
    comment_nickname = models.ForeignKey(Stranger,
           on_delete=models.CASCADE, related_name='+')
    comment_text = models.CharField(max_length=1000)

用户标识会话密钥是 request.session['stranger_id']。我正在考虑做这样的事情:

def got_comment(request):
    c = Comment(comment_text=request.POST['comment_text'],
             comment_nickname="""""")

但是我不知道在行尾写什么。

python
  • 1 个回答
  • 10 Views
Martin Hope
Антон
Asked: 2020-04-20 19:04:48 +0000 UTC

如何在 Django 中创建 URL 正则表达式

  • 2

我应该有 5 页:披萨、热食、饮料、甜点、沙拉。此网址无效:

r'^meals(?P<meal_name>[.]*)$'

我希望能够点击这样的链接: /catalog/mealspizza或/catalog/mealshot。

регулярные-выражения
  • 1 个回答
  • 10 Views

Sidebar

Stats

  • 问题 10021
  • Answers 30001
  • 最佳答案 8000
  • 用户 6900
  • 常问
  • 回答
  • Marko Smith

    我看不懂措辞

    • 1 个回答
  • Marko Smith

    请求的模块“del”不提供名为“default”的导出

    • 3 个回答
  • Marko Smith

    "!+tab" 在 HTML 的 vs 代码中不起作用

    • 5 个回答
  • Marko Smith

    我正在尝试解决“猜词”的问题。Python

    • 2 个回答
  • Marko Smith

    可以使用哪些命令将当前指针移动到指定的提交而不更改工作目录中的文件?

    • 1 个回答
  • Marko Smith

    Python解析野莓

    • 1 个回答
  • Marko Smith

    问题:“警告:检查最新版本的 pip 时出错。”

    • 2 个回答
  • Marko Smith

    帮助编写一个用值填充变量的循环。解决这个问题

    • 2 个回答
  • Marko Smith

    尽管依赖数组为空,但在渲染上调用了 2 次 useEffect

    • 2 个回答
  • Marko Smith

    数据不通过 Telegram.WebApp.sendData 发送

    • 1 个回答
  • Martin Hope
    Alexandr_TT 2020年新年大赛! 2020-12-20 18:20:21 +0000 UTC
  • Martin Hope
    Alexandr_TT 圣诞树动画 2020-12-23 00:38:08 +0000 UTC
  • Martin Hope
    Air 究竟是什么标识了网站访问者? 2020-11-03 15:49:20 +0000 UTC
  • Martin Hope
    Qwertiy 号码显示 9223372036854775807 2020-07-11 18:16:49 +0000 UTC
  • Martin Hope
    user216109 如何为黑客设下陷阱,或充分击退攻击? 2020-05-10 02:22:52 +0000 UTC
  • Martin Hope
    Qwertiy 并变成3个无穷大 2020-11-06 07:15:57 +0000 UTC
  • Martin Hope
    koks_rs 什么是样板代码? 2020-10-27 15:43:19 +0000 UTC
  • Martin Hope
    Sirop4ik 向 git 提交发布的正确方法是什么? 2020-10-05 00:02:00 +0000 UTC
  • Martin Hope
    faoxis 为什么在这么多示例中函数都称为 foo? 2020-08-15 04:42:49 +0000 UTC
  • Martin Hope
    Pavel Mayorov 如何从事件或回调函数中返回值?或者至少等他们完成。 2020-08-11 16:49:28 +0000 UTC

热门标签

javascript python java php c# c++ html android jquery mysql

Explore

  • 主页
  • 问题
    • 热门问题
    • 最新问题
  • 标签
  • 帮助

Footer

RError.com

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

帮助

© 2023 RError.com All Rights Reserve   沪ICP备12040472号-5