jpfreely

joined 1 year ago
 

When returning an immutable reference to a private struct field. (On mobile and used vertical bars instead of a bunch of HTML codes)

 

I started off avoiding mod.rs because it's the old way and I prefer having the module name as the filename. However, if the module needs a folder for submodules anyway, then there's a reason to tuck it away as mod.rs, especially if not doing so leaves lots of duplicate names (a.rs, b.rs, c.rs, ..., a/, b/, c/).

But then I don't really like to have much else in mod.rs other than mod declarations and pub use. Maybe a utility fn or a not-unwieldly implementation of struct "Foo", the module's namesake.

[–] jpfreely@programming.dev 1 points 1 year ago* (last edited 1 year ago)

Thanks for the feedback.

  • I'll definitely drop the Cypher prefix, and think it's a good idea to at least move the shorthand attribute macros to a crate feature. The readmes would use derive instead of the shorthand mostly.
  • ty::new() just uses the types in the struct (plus &str for String and &[T] for Vec). The extra builder struct is to help with updates, where you may want to just change a couple of fields, or bind it to editable UI fields.

I didn't realize how strong the rust presence is here. Experienced-devs on reddit is hard to go without :)

 

Hi everyone! I started learning rust about 3 months ago and had a sort of working version of this for my own needs, but spent some time (maybe lots) cleaning it up, testing it, and making it worthy of publishing.

https://crates.io/crates/cypher-dto

It's for working with Neo4j (cypher query language). It aims to assist in creating manual queries but provides unitary CRUD operations for nodes and relationships out of the box. Some other niceties:

Generates new(), getter methods, and a builder struct, and copies doc comments to them.

Has 'smart' handling of created/updated timestamp fields.

Supports multi-valued primary keys; uses the term "identifier" for that set of fields.

[–] jpfreely@programming.dev 2 points 1 year ago

That's the one problem. An LLM enhanced terminal sounds great. Sharing every command with the cloud does not.

[–] jpfreely@programming.dev 0 points 1 year ago* (last edited 1 year ago) (2 children)

I've had that article saved for years, it's still the best way to break down documentation imo.

Another key point for code documentation is that the closer it is to the code it's describing, the more likely it is to be read and maintained. The book "A philosophy of software design" has a section on it.