小编nul*_*ght的帖子

如何在安全的Rust中表达相互递归的数据结构?

我正在尝试在Rust中实现类似scenegraph的数据结构.我想在安全 Rust中表示这个C++代码的等价物:

struct Node
{
    Node* parent; // should be mutable, and nullable (no parent)
    std::vector<Node*> child;

    virtual ~Node() 
    { 
        for(auto it = child.begin(); it != child.end(); ++it)
        {
            delete *it;
        }
    }

    void addNode(Node* newNode)
    {
        if (newNode->parent)
        {
            newNode->parent.child.erase(newNode->parent.child.find(newNode));
        }
        newNode->parent = this;
        child.push_back(newNode);
    }
}
Run Code Online (Sandbox Code Playgroud)

我想要的属性:

  • 父母拥有其子女的所有权
  • 可以通过某种参考从外部访问节点
  • 触摸一个事件的事件Node可能会改变整个树

rust data-structures

23
推荐指数
3
解决办法
4415
查看次数

如何检测编译器

我必须从文件加载 ROM。Quartus 可以.mif直接使用文件,对于模拟器,我.mif在 textio 的帮助下编写了(一个快速而肮脏的)文件解析器。有没有办法检测合成器工具(在我的例子中是 Quartus)并仅在合成器工具未编译时生成 textio 文件加载器进程?

来源问题

vhdl

3
推荐指数
1
解决办法
1495
查看次数

ghdl在包中详细说明了一个实体

我有一个VHDL程序,我不能用GHDL来详细说明,因为要详细说明的实体是在一个包中.如何使用GHDL在包中详细说明实体?

编辑:

谢谢你的答案,经过一段时间我发现包中的代码就像一个接口,我们应该自己实现这个组件,我错误地认为它是完整的.抱歉错误的问题,我是VHDL的新手,我正在学习绳索,因为我的假设是错误的,所以无法在谷歌上找到任何解释.

vhdl ghdl

2
推荐指数
2
解决办法
1093
查看次数

标签 统计

vhdl ×2

data-structures ×1

ghdl ×1

rust ×1