TGViewer
Tact Kitchen Tact Kitchen @tact_kitchen · 505 subscribers
Post #18 846
⚡️ Added extension functions Struct.fromCell() and Struct.fromSlice()

Got tired of parsing Cells and you're certain of their structure?

Now you'll be able to call YourStruct.fromCell() and automagically get your Cells parsed! And it also works on Slices, with YourStruct.fromSlice()

Note, that those functions throw exceptions when the layout of a given Cell or Slice doesn't match the Struct's one.

Let's see them in action:

struct Profit {
big: String?;
dict: map<Int, Int as uint64>;
energy: Int;
}

contract MilkMoney with Deployable {
// 100% sure here
get fun gotProfit(src: Cell): Profit {
let profit = Profit.fromCell(src);
return profit;
}

// not 100% sure here,
// being cautious for good reasons
get fun gotProfitSlice(src: Slice): Profit? {
let profit: Profit? = null;
try {
profit = Profit.fromSlice(src);
catch (e) {
dump("Slice doesn't match Profit!");
}
return profit;
}
}

🧑‍🍳 Contributor: Gusarich
🐙 Implementation: #418
🍽 To be released in: v1.4.0 (right around the corner!)

🍲 You shall just parse!
♨️ @tact_kitchen
  • ⚡ 11
More from @tact_kitchen
  1. May 30, 2025🎉 Tact Language Server & VS Code Extension v0.8.0 are live! Smarter code insight, TL-B su…
  2. May 28, 2025🎉 Tact v1.6.12 is released! This is another joint release: both v1.6.11 and v1.6.12 were…
  3. May 22, 2025We’ve launched the ultimate hunt for bugs and hacker mastery — the epic CTF has begun at p…
  4. May 19, 2025🎉 Tact v1.6.10 is released! Recently, TVM version 10 was rolled out in the mainnet. It in…
  5. May 7, 2025For you all, JetBrains IDEs lovers: intelli-tact plugin release 📸 🍲 got IDEA? ♨️ @tact_k…
  6. May 7, 2025🎉 Tact v1.6.7 is released! We've been listening to your feedback and analyzing the code w…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →