What is it like to watch Giannis Antetokounmpo play in person?

An energetic block followed by galloping strides leading to a rim-rocking alley-oop. More unwavering applause. A post up with a turn around pump fake mixed in with a dribble and two more ridiculously…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Generics or Metaprogramming? Declarative macros with Rust

Smartly read inputs from standard input

Reading inputs from command line is probably the first task competitive coders do as they start to solve complex problems. While numerous languages are used by thousands of coders everyday, some emerge out as the popular ones; hello C++! One of the most powerful tools to write high performance programs. But… with great power, comes responsibility of managing memory *manually (Let’s not get into modern C++). While competitive coders do not care about (much) about de-allocating memory on an online judge, it is a pretty critical task for production systems to clean up and reclaim memory. Let’s bring our language into picture now; a language that offers several high level APIs, while being close to metal. Welcome to Rust!

Eh.. why mention C++ then?

This post will take 3 approaches to read input from standard input and will try to parse to required data type. For the sake of simplicity, let’s assume we wish to read a 32bit integer and a 32bit floating point number.

The concrete:

Can we not have 2 concrete implementations?
We sure can! Let’s quickly look at it:

While this gets the job done, but what if we want to extend our reader to other types? This approach will require rewriting another function altogether.

How about generics?

Add a comment

Related posts:

LD session 14

Always Arm yourself with questions that draw wisdom, An opportunity could arise where you are next to a Jeff Bezos, and your “Hey, how are you ” won’t get you anywhere God will give you a vision much…

The passion economy is changing the world!

Did you recently take a class on Skillshare instead of attending a university lecture?. Do you subscribe to a productivity mailing list from your favorite self-improvement coach?. Good for you, you…

I will design or customize your online store with woocommerce

Welcome to my gig! if you’re trying to find an experienced developer and want an eCommerce website or online store on a WordPress and if you want to customize premium theme and plugins of your choice…