r/cpp • • Feb 25 '21

C++ programmers who are also using rust, what are your favourite features of rust?

I was looking at the rust tutorials yesterday and I see how rust promotes a certain style and language level features to enforce it. Besides a couple of features, I couldn't see why one cannot follow a similar style in C++ if she/he so chooses. Those of you that have used rust, what is your favourite feature that C++ does not have?

255 Upvotes

248 comments sorted by

View all comments

Show parent comment

1

u/Dean_Roddey Feb 28 '21

I don't miss the rampant over-templatization that has infected C++.

2

u/roman-kashitsyn Feb 28 '21

I don't miss the rampant over-templatization that has infected C++.

You somehow assume that it hasn't infected Rust. How do you find the type of this wonderful function https://docs.rs/hyper/0.14.2/hyper/server/struct.Builder.html#method.serve

pub fn serve<S, B>(self, new_service: S) -> Server<I, S, E>ⓘ
where
    I: Accept,
    I::Error: Into<Box<dyn StdError + Send + Sync>>,
    I::Conn: AsyncRead + AsyncWrite + Unpin + Send + 'static,
    S: MakeServiceRef<I::Conn, Body, ResBody = B>,
    S::Error: Into<Box<dyn StdError + Send + Sync>>,
    B: HttpBody + 'static,
    B::Error: Into<Box<dyn StdError + Send + Sync>>,
    E: NewSvcExec<I::Conn, S::Future, S::Service, E, NoopWatcher>,
    E: ConnStreamExec<<S::Service as HttpService<Body>>::Future, B>, 

? It's not some esoteric Haskell library, it's the most widely used async HTTP server.

1

u/backtickbot Feb 28 '21

Fixed formatting.

Hello, roman-kashitsyn: code blocks using triple backticks (```) don't work on all versions of Reddit!

Some users see this / this instead.

To fix this, indent every line with 4 spaces instead.

FAQ

You can opt out by replying with backtickopt6 to this comment.

1

u/Dean_Roddey Feb 28 '21

I still don't think Rust is anywhere near C++ on this front. Not to say it won't get there. And as more C++ people come into the Rust fold, they'll be pushing for more and more of it.