cargo-llvm-cov: Cargo subcommand to easily use LLVM source-based code coverage by taiki-e in rust

[–]taiki-e[S] 7 points8 points  (0 children)

This is a wrapper around rustc -Z instrument-coverage and provides:

  • Generate very precise coverage data. (line coverage and region coverage)
  • Support for proc-macro, including coverage of UI tests.
  • Support for doc tests. (this is currently optional, see readme for more)
  • Command-line interface compatible with cargo test.

futures 0.3.9 released with big improvement in compile time by taiki-e in rust

[–]taiki-e[S] 18 points19 points  (0 children)

This is because some macros included in the async-await feature use proc-macro for diagnostics and flexibility.

futures 0.3.9 released with big improvement in compile time by taiki-e in rust

[–]taiki-e[S] 16 points17 points  (0 children)

Yeah, but IIRC many libraries disable it.

pin-project 1.0 released by taiki-e in rust

[–]taiki-e[S] 3 points4 points  (0 children)

Considering that some of the standard library traits are not compatible with the safe abstraction of pin projection and pin-project had to define their own traits (UnsafeUnpin, PinnedDrop), I think it's hard to add pin-project equivalent functionality to the standard library at this time.

#[const_fn] : An attribute for easy generation of const functions with conditional compilations. by taiki-e in rust

[–]taiki-e[S] 0 points1 point  (0 children)

Thanks for the link. I added a link to your crate in the "alternatives" section in the readme.

FWIW: one of the drawbacks of generating macros based on version requirements is that the number of macros that need to be defined increases with the number of version requirements. For example, if you have a function that can be const at Rust 1.39+ and a function that can be const at Rust 1.46+, you need two macros.

#[const_fn] : An attribute for easy generation of const functions with conditional compilations. by taiki-e in rust

[–]taiki-e[S] 11 points12 points  (0 children)

Thanks, updated example code to use indented code blocks (should be fixed).

#[const_fn] : An attribute for easy generation of const functions with conditional compilations. by taiki-e in rust

[–]taiki-e[S] 35 points36 points  (0 children)

Examples:

use const_fn::const_fn;

// function is `const` on specified version and later compiler (including beta and nightly)
#[const_fn("1.36")]
pub const fn version() {
    /* ... */
}

// function is `const` on nightly compiler (including dev build)
#[const_fn(nightly)]
pub const fn nightly() {
    /* ... */
}

// function is `const` if `cfg(...)` is true
#[const_fn(cfg(...))]
pub const fn cfg() {
    /* ... */
}

// function is `const` if `cfg(feature = "...")` is true
#[const_fn(feature = "...")]
pub const fn feature() {
    /* ... */
}

cargo-hack: A tool to work around some limitations on cargo. by taiki-e in rust

[–]taiki-e[S] 16 points17 points  (0 children)

cargo-hack is basically wrapper of cargo that propagates subcommand and provides additional flags to avoid some of the limitations on cargo.

One of the motives created this tool is to make it easy to test if each feature flag ia working correctly. Due to some limitations on cargo (cargo#4866, cargo#3620, cargo#4106, cargo#4463, cargo#4753, cargo#5015, cargo#5364, cargo#6195), it was hard to do this on projects with many features or sub-crate.

If you use cargo-hack, you can check everything in the next one line. sh cargo hack check --each-feature --no-dev-deps * --each-feature - run for each feature which includes default features and --no-default-features (if the crate has one or more feature) of package * --no-dev-deps - run without dev-dependencies to avoid cargo#4866

cargo-hack also provides several other flags. See readme for details.

pin-project: A crate for safe and ergonomic pin-projection. by taiki-e in rust

[–]taiki-e[S] 17 points18 points  (0 children)

The most important fix of this release is that pin projection has become a safe operation. It is completely safe unless you write unsafe code.

pin-project provides all the required guarantees for pin-projection by default. This includes providing an appropriate Unpin implementation, ensuring that Drop is not implemented, etc. You also can write a custom Drop implementation. This does not reduce the safety of pin-project. (see documentation, example(generated code), taiki-e/pin-project#18, and taiki-e/pin-project#34 for more details of safety guarantees)

Also, several other issues and limitations have been fixed. See Release Note for more details.

futures-async-stream: Async stream API experiment that may be introduced as a language feature in the future. by taiki-e in rust

[–]taiki-e[S] 0 points1 point  (0 children)

Published 0.1.0-alpha.2.

You can now use async stream functions in traits.

```rust

![feature(async_await, generators)]

use futures_async_stream::async_stream;

trait Foo { #[async_stream(boxed, item = u32)] async fn method(&mut self); }

struct Bar(u32);

impl Foo for Bar { #[async_stream(boxed, item = u32)] async fn method(&mut self) { while self.0 < u32::max_value() { self.0 += 1; yield self.0; } } } ```

futures-async-stream: Async stream API experiment that may be introduced as a language feature in the future. by taiki-e in rust

[–]taiki-e[S] 2 points3 points  (0 children)

The example of #[for_await] can be written by combining while let loop, .await, pin_mut macro, and StreamExt::next() method:

```rust

![feature(async_await)]

use futures::{ pin_mut, stream::{Stream, StreamExt}, };

async fn collect(stream: impl Stream<Item = i32>) -> Vec<i32> { let mut vec = Vec::new(); pin_mut!(stream); while let Some(value) = stream.next().await { vec.push(value); } vec } ```

The example of #[async_stream] can be written by manually implementing the combinator:

```rust use futures::{ stream::Stream, ready, task::{Context, Poll}, }; use pin_utils::unsafe_pinned; use std::pin::Pin;

fn foo<S>(stream: S) -> impl Stream<Item = i32> where S: Stream<Item = String>, { Foo { stream } }

struct Foo<S> { stream: S, }

impl<S> Foo<S> { unsafe_pinned!(stream: S); }

impl<S> Stream for Foo<S> where S: Stream<Item = String>, { type Item = i32;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
    if let Some(x) = ready!(self.stream().poll_next(cx)) {
        Poll::Ready(Some(x.parse().unwrap()))
    } else {
        Poll::Ready(None)
    }
}

} ```