Greetings everyone, my first post on the forum (was reluctant to posting this on SO). I have very recently started working with Rust
and have never delved into this programming paradigm before (which is honestly fascinating). The drawback I’m experiencing right now is having to rethink everything about design and behaviour to what I’m more familiar with.
I’ve been wanting to port yattag over to rust as I need to generate an enormously large number of HTML files as fast as possible; however before doing that I want to properly learn the language and the paradigm itself.
For instance–I would require a Tag
struct which is able to maintain a property of itself like so:
struct Tag {
tag: Tag,
doc: &str,
name: &str,
attrs: &Vec<String>;
}
Which does not compile due to lifetime specifier being required. Thus I decide to convert this slightly to:
struct Tag<'a>
...
tag: &'a Tag,
…however the compiler states that error is due to the wrong number of lifetime parameters: expected 1, found 0
.
I presume I’m just not structuring this right at all. The idea behind this is to be able to get both the current
and parent
tag.