Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Ariel (馃惪 arc)
@arichtman@eigenmagic.net  路  activity timestamp 2 weeks ago

Is it possible to bind explicit lifetimes /between/ struct fields? Or only between structs themselves and their fields like a parent-child thing?

I want a master vector of actual resources and a hashmap where the values are references back into the master vector.

Idk I'm probably approaching this wrong

#RustLang #Rust

struct MyStruct<'owner> {
    map_of_references: HashMap<String, &'owner String>,
    master_collection: Vec<String<'owner>>,
}
struct MyStruct<'owner> { map_of_references: HashMap<String, &'owner String>, master_collection: Vec<String<'owner>>, }
struct MyStruct<'owner> { map_of_references: HashMap<String, &'owner String>, master_collection: Vec<String<'owner>>, }
  • Copy link
  • Flag this post
  • Block
Ariel (馃惪 arc)
@arichtman@eigenmagic.net replied  路  activity timestamp 2 weeks ago

@algernon @sjolsen @jaxter184 @EndlessMason

What I was trying to do here was use data structures like HashMap to get different views into the same resources.

Node groups have some properties but also I need to be able to list all the nodes for a given group.
At the same time, sometimes I just need to locate a node by it's ID, without caring about the group.

HashMaps made finding one or the other by ID easy, but not so the other way around.

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About 路 Code of conduct 路 Privacy 路 Users 路 Instances
Bonfire social 路 1.0.0-rc.3.1 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login