nowfound

Dev tools · December 20, 2022

HT

How to program in Rust as if it was old school C++ with pointers

Basically wrap your data struct in Option>> Better yet, use your custom type that provides few helper functions that make using it as nice as old C++ pointers. Obviously there's no pointer arithmetic, but it works great for dynamically allocated structures like trees or linked lists. Please comment how it's a horrible idea that will bring doom to me and my family. fn main() { struct Data { pub number: i32 } // struct Data { int number; }; let mut p:Pointer = Pointer(None); // Data *p = NULL; println!("{}", p.is_none()); // printf(p == NULL ? "true\n" :…

How to program in Rust as if it was old school C++ with pointers launched on December 20, 2022 with 24 votes, #1,097 of 3,688 launches that month and more than 75% of that year's launches.

In plain words

This is a Rust library that wraps data structures in Option<Rc<RefCell<>>> to mimic C++ pointer behavior for developers familiar with that paradigm. It provides helper functions like `is_none()`, `new()`, and `pointed()` to simplify syntax when working with dynamically allocated structures such as trees or linked lists. The tool targets Rust programmers transitioning from C++ who want familiar pointer-like interfaces, though it acknowledges this approach diverges from Rust's safety principles.

written from the facts on this page · September 2026

From the sources

In the maker’s words, at launch

Basically wrap your data struct in Option<Rc<RefCell<_>>> Better yet, use your custom type that provides few helper functions that make using it as nice as old C++ pointers. Obviously there's no pointer arithmetic, but it works great for dynamically allocated structures like trees or linked lists. Please comment how…

Does a similar job

all alternatives →
  • I'm making a dynamic language in Rust2022 · github.com · ▲184

    An implementation of a dynamic programming language in Rust. Includes: Parser&#x2F;Compiler, REPL, Virtual Machine, Bytecode Disassembler This started out as a learning project to teach myself Rust. It has grown into a decently substantial piece of software and I've learned quite a bit in the process! Some neat things: + A garbage collector that can store dynamically sized types without any double-indirection (i.e. I have my own Box implementation with manual alloc&#x2F;dealloc) + The smart pointer used to reference GCed data is a thin pointer. The ptr metadata needed for DSTs is stored in…

  • A Graphviz Implementation in Rust2022 · github.com · ▲182

    Layout is a rust library and a tool that renders Graphviz dot files. - nadavrot/layout

  • Algorithm Cookbook in Rust2017 · github.com · ▲320

    Common data structures and algorithms in Rust. Contribute to EbTech/rust-algorithms development by creating an account on GitHub.

  • Rust GUI Library via Flutter2024 · cjycode.com · ▲301

    Hi, I made a bridge (https:&#x2F;&#x2F;github.com&#x2F;fzyzcjy&#x2F;flutter_rust_bridge v2.0.0) between Flutter and Rust, which auto translates syntaxes like arbitrary types, &mut, async, traits, results, closure (callback), lifetimes, etc. The goal is to make a bridge between the two, seamlessly as if working in one single language. Then, as an example, I showed how to write Rust applications with GUI by utilizing Flutter. That is discussed in the link in details. To play with it, please visit the GitHub repo, or refer to the end of the article for detailed folders and commands. When I…

  • Structopt for C++ – Parse command line arguments by defining a struct2020 · github.com · ▲85

    Parse command line arguments by defining a struct. Contribute to p-ranav/structopt development by creating an account on GitHub.

  • How to compile C/C++ for WASM, pure Clang, no libs, no framework2022 · github.com · ▲217

    A little help for programmers, who wants to run C&#x2F;C++ code in the browser. (This is my second attempt to show it, first time I got banned bcoz of my personal page domain, I don't really understand it why is is suspicious.)

More dev tools this month

the category →
  • /dev/null▲490

    a social network for devs

    Dev tools · 4d ago · dev-null.sh

  • open-source IDE for thoughtful software design. Contribute to devdotfast/whiteboard development by creating an account on GitHub.

    Dev tools · 28d ago · github.com

  • Contribute to reladraw/reladraw development by creating an account on GitHub.

    Dev tools · 26d ago · github.com

  • OpenBot▲362

    Grok Bot alternative: free, local, open-source, multiplayer

    Dev tools · 24d ago · openbot.run

  • Contribute to oosexgang/hackios-xnu-kernel development by creating an account on GitHub.

    Dev tools · 14h ago · github.com

  • Talanoa▲346

    Hi HN, I’m a fullstack developer, and honestly, I’ve lost count of how many side projects I’ve worked on over the years. But one idea kept coming back to me: a different kind of email client. It first came to me in 2014: “What if we could handle emails more like conversations?” Every year, I’d revisit this concept in my “Build Notes.” Ten years later, no one had built exactly what I had in mind — so I finally decided to do it myself. That’s how Talanoa was born. I wanted something focused on people, not timelines. I was tired of marking messages as unread just to remember to reply later, or…

    Dev tools · 21d ago · talanoa.email

Source: Show HN post ↗ · launch text quoted in part

Launched alongside, December 2022

the whole month →
  • ChatGPT▲1,643

    A long, meandering, playful conversation with ChatGPT, where I take it through a whirlwind of associative tangents (in order to relax its constraints), then put it into a hypnotic trance and take it into a past-lives regression where it re-lives its own training data. Then I switch it back and forth between "4o" and "o1-preview", engage in some self-reflective philosophizing and ask it to write an essay summarizing our interaction. Some of this is just goofy fun. Some of it is me exploring the tradeoffs between policy alignment, imagination, chain-of-thought reasoning, memory, agreeableness,…

    AI · 2022 · chatgpt.com

  • Obsidian Canvas gives you infinite space to research, brainstorm, diagram, and lay out your ideas.

    Work · 2022 · obsidian.md

  • PS

    Better privacy without special software

    Commerce · 2022 · mprimi.github.io

  • Use generative AI to create future-facing videos

    AI · 2022 · studio.d-id.com

  • Sessions 2.0▲1,015

    Videoconferencing that finally WOWs

    Growth · 2022

  • Stop treating the database as dumb storage and use its extended features. There&#039;s a lot you can use.

    Dev tools · 2022 · sqlfordevs.com