Ce

Certain Map, a Rust typed map which can make sure item exist

Hacker News

Certain Map, a Rust typed map which can make sure item exist

When using Tower Service or other similar onion model components, we have long faced a problem: cross-component information passing. Usually there are 2 solutions: 1. Define a new Request/Response type. When `inner.call()`, the information passed by the outer Service and the information obtained by this Service are combined into a new structure and passed down. The advantage of this is that it can ensure that the value exists, but the disadvantage is that you have to repeatedly define a new structure to store the merged information, and this kind of code will be very redundant. 2. Using a HashMap/TypeMap, the Map itself will be passed across Services, and each Service can inserte and delete values at will. The advantage of doing this is that it is really convenient and the code is clean; but the problem is that the existence of a specific kv depends entirely on the agreement. If the person in front forgets to set it, the later will panic when reading it(or bring unreasonable error handling logic which not expected to happen). This problem comes up many times in out RPC framework. Here I use rust's type system to encode whether the key exists or not into the type. Adding or deleting a key means a type change, so that we can constrain the existence of a certain key, check at compile time, and say goodbye to this problem and the panic it caused. To a certain extent, this sentence is re-fulfilled: If it compiles, it works. If you have the need to transfer information across Services, you will definitely like it.

Share card

Actual performance

3points
Did not reach leaderboard

Launch Intel predictions

Analyze your own launch →
Product HuntOn track for Day 1 leaderboard · Strong signals: model, new, using · Missing: mac, agents, macos
72%72% predicted probability of success on Product Hunt, based on ML models trained on real launch data.
best fitHighest predicted score across all platforms for this description.
Indie HackersFits the IH revenue-focused audience · Missing: supports, reddit linkedin, podcasting
57%57% predicted probability of success on Indie Hackers, based on ML models trained on real launch data.
Hacker NewsStrong engagement from HN community · Strong signals: exist, io · Missing: https docs, excited, just released
51%51% predicted probability of success on Hacker News, based on ML models trained on real launch data.
nativeThis product was originally launched on this platform.
TrustMRRLess likely to generate early MRR · Missing: mobile apps, ios, personal
38%38% predicted probability of success on TrustMRR, based on ML models trained on real launch data.
AppSumoMay struggle as an AppSumo deal · Missing: plus, platform, intuitive
34%34% predicted probability of success on AppSumo, based on ML models trained on real launch data.
Acquire.comPre-revenue stage for this audience · Missing: arr, mrr, revenue
12%12% predicted probability of success on Acquire.com, based on ML models trained on real launch data.
BetaListMay not resonate with beta-testers · Missing: web3, chat, crypto
0%0% predicted probability of success on BetaList, based on ML models trained on real launch data.

Incorrect prediction on native model

Similar products

No
Not Sure What To Make?39%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Not Sure What To Make?

Hacker News1
Ma
Map of 2015 terrorist attack57%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Map of 2015 terrorist attack

Hacker News1
Ri
Rightmove + Zoopla + Gumtree properties on one map37%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Rightmove + Zoopla + Gumtree properties on one map

Hacker News1
Ri
Rightmove + Zoopla + Gumtree properties on one map37%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Rightmove + Zoopla + Gumtree properties on one map

Hacker News1
Vi
Vines on a map51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Vines on a map

Hacker News1
Ma
March Madness map, made in D357%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

March Madness map, made in D3

Hacker News1
To
Tokyo Wind Map51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Tokyo Wind Map

Hacker News4
Ki
Kish Map51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Kish Map

Hacker News24
Fi
Fishing Map for RI51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Fishing Map for RI

Hacker News3
Mi
Minard's map of Napoleon's invasion of Russia51%Launch Intel prediction score: how likely this product is to succeed on its source platform, based on its name, tagline, and description.

Minard's map of Napoleon's invasion of Russia

Hacker News49