profile
viewpoint
bluss bluss Low Earth Orbit Debris Field https://github.com/bluss/rustfaq I work on Rust, I teach Rust.

bluss/arrayvec 211

A vector with a fixed capacity. (Rust)

bluss/bencher 37

bencher is just a port of the libtest (unstable) benchmark runner to Rust stable releases. `cargo bench` on stable. "Not a better bencher!" = No feature development. Go build a better stable benchmarking library.

bluss/defmac 10

A macro to define lambda-like macros inline.

bluss/debugit 8

NOTE: Crate dbg mostly supplants this one; DebugIt: Use specialization so you can debug-print a value without explicit (and viral) Debug trait bound.

bluss/asprim 2

Rust library with a trait for the `as` operator for primitive numeric types.

bluss/blake2-ppc-altivec 2

BLAKE2s hash function https://blake2.net PowerPC/Altivec implementation by Ulrik Sverdrup

bluss/aeon 1

Aeon is a gradually typed, interpreted programming language that combines the flexibility of a dynamic language with the safety of a static language.

bluss/blis-sys 1

[Feel free to adopt/fork this repo!] Experimental Rust bindings for BLIS

bluss/bmap 1

Experimental B-tree map in Rust using ArrayVec

issue commentbluss/matrixmultiply

error: array lengths can't depend on generic parameters

Thanks! As you know, this code compiles since Rust 1.28, so it's unfortunate that it is broken on nightly.

jonathanstrong

comment created time in a month

issue commentrust-ndarray/ndarray

Cannot define strides in `zeros` constructor

Yes, it is intentional. What kinds of strides are desired in your use case?

chocol4te

comment created time in a month

startedBLAKE3-team/BLAKE3

started time in a month

starteddtolnay/cxx

started time in a month

issue commentpetgraph/petgraph

Release new version

Thanks xvilka!, my usual dev env is not running, so I can't push the release right now, but can eventually. Would be cool if others could publish

ignatenkobrain

comment created time in 2 months

pull request commentpetgraph/petgraph

Fix elements emitted by min_spanning_tree on StableGraph

Thanks that's great. Do you know if it can be made non breaking by using node indexable - node IDs as integers.

carrutstick

comment created time in 2 months

startedLeonHartley/Coerce-rs

started time in 2 months

issue commentbluss/arrayvec

Don't care about the array size

I think any solution I see here requires dynamic dispatch. If you go to use a Box as backing store, then it sounds like just using Vec would be even better, not using arrayvec.

piegamesde

comment created time in 3 months

issue commentbluss/arrayvec

Don't care about the array size

It seems like you need a trait yes, maybe something that even Vec can implement. You might as well prototype this out of crate, that's more productive for you, and at this point it is unlikely we would include it in arrayvec itself, unless we have a very promising prototype.

piegamesde

comment created time in 3 months

pull request commentbluss/arrayvec

Miri now supports catching panics

Thanks!

RalfJung

comment created time in 3 months

push eventbluss/arrayvec

Ralf Jung

commit sha 7ae9e2cd1f1fbfa99c74f3676b8026d46fdb076a

Miri now supports catching panics

view details

bluss

commit sha 4f0faaf0274f7e3fca13417795a5ccf3253f033a

Merge pull request #155 from RalfJung/miri Miri now supports catching panics

view details

push time in 3 months

PR merged bluss/arrayvec

Miri now supports catching panics
+1 -1

0 comment

1 changed file

RalfJung

pr closed time in 3 months

issue commentrust-ndarray/ndarray

Mutable slices must be in variable

Another thing that comes to mind is += used on interior mutable paths to values.

nilgoyette

comment created time in 3 months

issue commentrust-ndarray/ndarray

Mutable slices must be in variable

I'd like that we gather these kinds of lang concerns and bring them to the community for possibly improving Rust in the long term. Other operator limitations also apply I think, including indexing.

nilgoyette

comment created time in 3 months

issue commentrust-lang/crates.io

Download breakdown by compatible versions

This still seems useful to me! I can see it has not gotten much attention in terms of +1's but it might be a quite invisible issue.

bluss

comment created time in 3 months

issue closedrust-ndarray/ndarray

Source code page in documentation does not show up correctly

If I go to the documentation, for example https://docs.rs/ndarray/0.12.1/ndarray/struct.ArrayBase.html and clicks source code [src] of some method, then the link directs to a white page that contains only highlighted line numbers but no visible source code. If I scroll down, source code is there, but at the bottom of the page. For example https://docs.rs/ndarray/0.12.1/src/ndarray/lib.rs.html#1026-1039

This behaviour has not happened with other rust documentations before, so I guess this may be fixable by ndarray side. It is still quite weird that auto-generated documentation does not show up properly.

Tested web browsers: Firefox / Chromium on Ubuntu 19.10.

closed time in 3 months

tolvanea

issue commentrust-ndarray/ndarray

Source code page in documentation does not show up correctly

It was a bug in rustdoc, and it's fixed (see the ndarray 0.13 docs). It would be a docs.rs issue to update the old documentation, but I don't think it will happen.

tolvanea

comment created time in 3 months

issue closedbluss/arrayvec

CI should fail, if the code isn't rustfmted

See https://github.com/rust-lang/rustfmt#checking-style-on-a-ci-server

closed time in 3 months

Luro02

issue commentbluss/arrayvec

CI should fail, if the code isn't rustfmted

This is always something that current maintainers will decide about. Presently, this does not add value.

Luro02

comment created time in 3 months

issue commentrust-ndarray/ndarray

Memmap supported? For accessing large data

@daCapricorn we'd be curious to hear about how it works, what doesn't work and performance and such things!

daCapricorn

comment created time in 3 months

issue commentrust-ndarray/ndarray

Memmap supported? For accessing large data

ArrayViewMut can be created from arbitrary slice or raw pointer and shape information, so it's possible that way. The same size limits still apply (can't access memory with greater distance from start to end than isize:::MAX).

daCapricorn

comment created time in 3 months

pull request commentrust-ndarray/ndarray

Issue/655: Standard deviation and variance

I don't quite see the issue with using Zip here

allmywatts

comment created time in 3 months

issue commentrust-itertools/itertools

iproduct! can't be used with more than 8 iterators

It's an itertools problem but I think it is a reasonable one, shouldn't add too many more impls (they would be unused and still cost compile time).

steven-joruk

comment created time in 3 months

push eventbluss/arrayvec

nicbn

commit sha 633c863b0a7a8a06a8aa41fb77970abad3497cc1

Add is_empty method for ArrayVec and ArrayString

view details

bluss

commit sha badc118d6aa5e6028df8e619b1cc9e3db076bef0

Merge pull request #143 from nicbn/is_empty Add is_empty method for ArrayVec and ArrayString

view details

push time in 3 months

PR merged bluss/arrayvec

Add is_empty method for ArrayVec and ArrayString

As per clippy hint (it's clearer and more specific than comparing len() against 0).

+16 -0

3 comments

2 changed files

nicbn

pr closed time in 3 months

pull request commentbluss/arrayvec

Add is_empty method for ArrayVec and ArrayString

Merged because of what was previously said (I'm not a fan of the clippy hint - is_empty is clearly already provided).

nicbn

comment created time in 3 months

push eventbluss/arrayvec

Ralf Jung

commit sha 9beb753473482c7f4e8b809aefdcf3300d525267

fix aliasing in drain_range

view details

Ralf Jung

commit sha 9ed6941a5162026ba96c55a2270d6420839f723e

run miri on CI

view details

bluss

commit sha 481c8ab6831074f283689c16307c6029b41b27fc

Merge pull request #144 from RalfJung/miri fix drain_range in Miri and add Miri to CI

view details

push time in 3 months

PR merged bluss/arrayvec

fix drain_range in Miri and add Miri to CI
+25 -3

1 comment

5 changed files

RalfJung

pr closed time in 3 months

pull request commentbluss/arrayvec

fix drain_range in Miri and add Miri to CI

Thanks!

RalfJung

comment created time in 3 months

push eventbluss/arrayvec

Phlosioneer

commit sha 33d5d2ed9600977feab7c8ff8df85162f4d41efe

Fix outdated comment Comment referenced NoDrop which is no longer used.

view details

bluss

commit sha 3095e0e4e366e65eef20ce577680efd4034fe765

Merge pull request #146 from Phlosioneer/patch-1 Fix outdated comment

view details

push time in 3 months

PR merged bluss/arrayvec

Fix outdated comment

Comment referenced NoDrop which is no longer used.

+1 -3

1 comment

1 changed file

Phlosioneer

pr closed time in 3 months

pull request commentbluss/arrayvec

Fix outdated comment

Thanks1

Phlosioneer

comment created time in 3 months

issue commentrust-ndarray/ndarray

Is it possible to collect a Zip into Array?

Seems like a reasonable feature request long-term.

xiaoniu-578fa6bff964d005

comment created time in 3 months

startedLokathor/wide

started time in 3 months

startedtermhn/rayn

started time in 3 months

issue commentbluss/arrayvec

Rename `try_extend_from_slice`

It's called extend from slice on Vec, so that is the naming precedent that is used.

piegamesde

comment created time in 3 months

pull request commentbluss/arrayvec

Add is_empty method for ArrayVec and ArrayString

Super minor point but len should exist here as on Vec, because we want to be able to access the fundamental properties (length and pointer to backing store) without going through deref (going through a potentially temporarily invalid or uninit &[T]), for maximal flexibility and correctness for unsafe code. This was the reason Vec was complimented with Vec::as_ptr in Rust 1.37 and ArrayVec follows that idea.

I'm not a fan of the duplication, but the same reasoning makes it valid to add is_empty because it is a variation of len.

nicbn

comment created time in 3 months

pull request commentrust-lang/rust

Proposal: `fold_self` and `try_fold_self` for Iterators

Yes, fold1 in itertools is equivalent

Lucretiel

comment created time in 3 months

issue commentrust-ndarray/ndarray

Iteration performance for 'f' same-order arrays

Thanks for adding all that! Not sure what you mean about the std_iter_ benchmarks (those are interesting to have for completeness, though).

nilgoyette

comment created time in 3 months

issue commentbluss/arrayvec

ArrayString::from_raw_parts

Ping me if we should look closer at making a working shim for using write! on &mut [u8]

NickeZ

comment created time in 3 months

issue commentbluss/arrayvec

ArrayString::from_raw_parts

It's not something I'll do now, but providing your own shim for this should not be impossible. See https://doc.rust-lang.org/nightly/src/std/io/mod.rs.html#1219-1448 (std::io::Write::write_fmt source), and you can simplify it by having simpler error handling.

NickeZ

comment created time in 3 months

issue commentbluss/arrayvec

ArrayString::from_raw_parts

Oh right. So all the non-std+allcoc Work is still somewhat of a futile exercise, that's good to know.

I'd look next at core_io or similar I'd it doesn't let you do the equivalent thing as std io Write.

For ArrayString, the capacity is type level information and there is only so much we can do given a buf_len as input, you'd have to insert some logic that picks a long enough ArrayString and abstracts the varying ArrayString type.

NickeZ

comment created time in 4 months

issue commentbluss/arrayvec

ArrayString::from_raw_parts

Hallå!

First I'll have to ask if you can't just use the native Write support of &mut [u8] itself.

use std::io::Write;

unsafe fn do_something(buf: *mut u8, buf_len: usize) {
    let mut s = std::slice::from_raw_parts_mut(buf, buf_len);
    write!(s, "fancy formatting {}", 2.71828).unwrap();
    let remaining_length = s.len();
    println!("Remaining={}", remaining_length);
}

fn main() {
    let mut data = [0; 100];
    unsafe { do_something(data.as_mut_ptr(), data.len()); }
    println!("{:?}", std::str::from_utf8(&data));
}

Constucting an ArrayString from a pointer only makes sense to me if the operation that would do would be to copy data through the pointer, into a new ArrayString. Since the ArrayString stores its data inline, we can't tell it to store its data at a particular pointer.

NickeZ

comment created time in 4 months

pull request commentrust-lang/rust

proposal for BTreeMap/Set min/max, #62924

@Centril can I reassign this? I won't have the time unfortunately

ssomers

comment created time in 4 months

pull request commentbluss/arrayvec

impl diesel::deserialize::FromSql for ArrayString

Probably arrayvec does not want to have a public dependency on diesel

AtsukiTak

comment created time in 4 months

Pull request review commentbluss/arrayvec

impl diesel::deserialize::FromSql for ArrayString

 impl<'de, A> Deserialize<'de> for ArrayString<A>         deserializer.deserialize_str(ArrayStringVisitor::<A>(PhantomData))     } }++#[cfg(feature="diesel")]+/// Requires crate feature `"diesel"`+impl<A, ST, DB> FromSql<ST, DB> for ArrayString<A>+    where A: Array<Item = u8> + Copy,+          DB: Backend,+          *const str: FromSql<ST, DB>+{+    fn from_sql(bytes: Option<&DB::RawValue>) -> diesel::deserialize::Result<Self> {+        let str_ptr = <*const str as FromSql<ST, DB>>::from_sql(bytes)?;+        // never be null+        let string = unsafe { &*str_ptr };+        Self::from(string)+            .map_err(|e| Box::new(e.simplify()) as Box<(dyn std::error::Error + Send + Sync)>)

Is there a missing free for str_ptr, or what's the ownership semantics of it?

AtsukiTak

comment created time in 4 months

Pull request review commentbluss/arrayvec

impl diesel::deserialize::FromSql for ArrayString

 impl<'de, A> Deserialize<'de> for ArrayString<A>         deserializer.deserialize_str(ArrayStringVisitor::<A>(PhantomData))     } }++#[cfg(feature="diesel")]+/// Requires crate feature `"diesel"`+impl<A, ST, DB> FromSql<ST, DB> for ArrayString<A>+    where A: Array<Item = u8> + Copy,+          DB: Backend,+          *const str: FromSql<ST, DB>+{+    fn from_sql(bytes: Option<&DB::RawValue>) -> diesel::deserialize::Result<Self> {+        let str_ptr = <*const str as FromSql<ST, DB>>::from_sql(bytes)?;

What's the argument for this code being correct? What does FromSql do for *const str ?

AtsukiTak

comment created time in 4 months

issue commentrust-ndarray/ndarray

Zip::indexed performance for same-order arrays

Please make this more specific with some example code, at least the stanzas that call Zip

nilgoyette

comment created time in 4 months

starteddeezer/spleeter

started time in 4 months

pull request commentrust-lang/rust

proposal for BTreeMap/Set min/max, #62924

I'm sorry, I haven't had time to review, still expect to do it, but don't mind someone else jumping in.

ssomers

comment created time in 4 months

issue commentbluss/indexmap

serde feature is incompatible with no_std

I think we can solve this with a new feature like serde-no-std, subset of current serde feature

CryZe

comment created time in 4 months

issue commentbluss/indexmap

serde feature is incompatible with no_std

Thanks. What's your opinion on the feature detect approach to no-std that indexmap uses?

CryZe

comment created time in 4 months

issue commentpetgraph/fixedbitset

Implement bit iterator

Sounds cool, but I think we will struggle to deliver good performance through Iterator::next (maybe fold will be fine). The filtering operation could maybe even have a more specialized api.

Veykril

comment created time in 4 months

issue commentrust-lang/docs.rs

Trailing whitespace lead to no matches

I ran across this bug today. The message that is given for no matches is "The requested resource does not exist", which is also not quite clear, it gives the impression that there was an error, not just that no results matched the search.

Test url for search 'ndarray '

Boscop

comment created time in 4 months

delete branch bluss/rust

delete branch : no-drop-in-union-fields

delete time in 4 months

pull request commentrust-itertools/itertools

0.9.0 release

Nice going. do you know if it needs to be a breaking update?

danielhenrymantilla

comment created time in 4 months

pull request commentrust-lang/rust

Change untagged_unions to not allow union fields with drop

Awesome. Thanks to all that worked on this!

SimonSapin

comment created time in 4 months

push eventrust-ndarray/ndarray

bluss

commit sha 4d9fe12c84645b8728d92835aa8ab0384c452710

Use the same features, so we can compare time (duh)

view details

push time in 4 months

push eventrust-ndarray/ndarray

bluss

commit sha 1816f853158654846a637dbc0dd13efd6af2cb8a

WIP changes to lld test

view details

push time in 4 months

push eventrust-ndarray/ndarray

bluss

commit sha fdaf003995929936a8da7f66515f495fdc085630

WIP changes to lld test

view details

push time in 4 months

create barnchrust-ndarray/ndarray

branch : lld

created branch time in 4 months

startedrust-lang/unsafe-code-guidelines

started time in 4 months

startedgeorust/geo

started time in 4 months

issue commentrust-lang/rust

array impls <= 32 1.39 regression

Formatting the first it points to this:

error[E0277]: arrays only have std trait implementations for lengths 0..=32
   --> src/lib.rs:362:5
    |
362 |     pub data: [::std::os::raw::c_char; 128usize],
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::array::LengthAtMost32` is not implemented for `[i8; 128]`
    |
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `[i8; 128]`
    = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[i8; 128]`
    = note: required for the cast to the object type `dyn std::fmt::Debug`

And it fails to compile in Rust 1.37, 1.38 as well, so it's not a regression. Since this is generated code, it could be that it's a change in what code is being generated, but it seems unlikely?

Mark-Simulacrum

comment created time in 4 months

issue commentrust-lang/rustup.rs

Shrink size of default installation

This bug was reported by citing the duplicate files that exist inside the same specific toolchain install. What I can see, some of these still remain. I don't think this has been solved, for that reason.

bluss

comment created time in 4 months

pull request commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

Thanks! @bors r+ rollup

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 impl<T: fmt::Debug> fmt::Debug for Difference<'_, T> { /// [`BTreeSet`]: struct.BTreeSet.html /// [`symmetric_difference`]: struct.BTreeSet.html#method.symmetric_difference #[stable(feature = "rust1", since = "1.0.0")]-pub struct SymmetricDifference<'a, T: 'a> {-    a: Peekable<Iter<'a, T>>,-    b: Peekable<Iter<'a, T>>,-}+pub struct SymmetricDifference<'a, T: 'a>(MergeIterInner<Iter<'a, T>>);  #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for SymmetricDifference<'_, T> {     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        f.debug_tuple("SymmetricDifference")-         .field(&self.a)-         .field(&self.b)-         .finish()+        f.debug_tuple("SymmetricDifference").field(&self.0).finish()

It has been decided that it is not necessary to have type information in the Debug formats, but structs usually have their name (for clarity I guess). The nameless set probably begins with the nameless Vec formatting, which comes naturally from delegating to the slice's formatting, which is also nameless.

Keep it consistent if you want. We shouldn't go out to change unrelated code in this PR, and changing this to use stringify in the whole crate is probably needlessly contentious.

ssomers

comment created time in 4 months

issue commentrust-lang/rfcs

Add impl TryFrom<T> for E where E is a C-like #[repr(T)] enum

I don't know the details of proc macros that well, will the derive always see the repr attribute, or is there an ordering issue?

canndrew

comment created time in 4 months

issue commentpetgraph/petgraph

StableGraph::from_elements(min_spanning_tree(&graph)) asserts that node does not exist in graph

It's weird that we have this oversight, but more analysis during fixing will answer if it's possible and a good design to keep the node indices through these APIs. From the design of FromElements, I don't think so.

bonsairobo

comment created time in 4 months

pull request commentrust-lang/rust

implement FromIterator<char> for Box<str>

It should be 1.40.0

Duddino

comment created time in 4 months

pull request commentrust-ndarray/ndarray

Implement arithmetic ops on more combinations of types

It's nice to express, but it risks cementing one of the things we want to fix - excessive cloning?

I don't think it's right to change the return type of ArcArray<T> + T or similar. That should still be ArcArray. This is still the spirit of predictiveness. We want to preserve the kind of the array if we can, and we even want to preserve the layout of the array if we can (if the user uses F arrays, we return those where reasonable).

jturner314

comment created time in 4 months

pull request commentrust-lang/rust

Proposal: `fold_self` and `try_fold_self` for Iterators

If there is no proposed use case for try_fold_first, can it be skipped?

For the tidy error, barring splitting the file now, there is an opt-out of the warning you can apply, adding // ignore-tidy-filelength in the file (see other source files with this incantation).

Lucretiel

comment created time in 4 months

issue commentbluss/indexmap

DOC: Comparison with HashMap

Well, it's certain that indexmap doesn't compete with hashbrown for performance in general. There are some special cases where indexmap might be faster, like for example iteration.

bluss

comment created time in 4 months

created tagbluss/indexmap

tag1.3.0

A hash table with consistent order and fast iteration; access items by key or sequence index

created time in 4 months

push eventbluss/indexmap

bluss

commit sha 899fc93a0b5872d7101ef6c7dcfb2311c2cb0f32

DOC: Add a doc section drawing attention to some extra features

view details

bluss

commit sha 4868359456872cb91a9734b2d5408bcdbfda3ff3

DOC: Edit README and release notes for 1.3. Clean up a bit in the readme.

view details

bluss

commit sha c8204515dc1f5bc74c89ca440ecbaa470f30520d

1.3.0

view details

push time in 4 months

issue commentpetgraph/petgraph

StableGraph::from_elements(min_spanning_tree(&graph)) asserts that node does not exist in graph

ok, looks like a bug. as a workaround until it's solved please create a Graph from the iter, then convert to StableGraph.

bonsairobo

comment created time in 4 months

PR closed bluss/either

Make `Either` be `As{Ref,Mut}` over `?Sized` types

The blanket impl can cover all unsized types, removing the need for an impl per specific unsized type.

+2 -57

2 comments

1 changed file

nvzqz

pr closed time in 4 months

pull request commentbluss/either

Make `Either` be `As{Ref,Mut}` over `?Sized` types

I'll close this since we don't have a plan for 2.0 at the moment.

Consider the different roles crates have. Crates that are used privately (local to a crate) have an easier time to go from 1.0 to 2.0. Say for example lazy_static. If you update that crate, it probably does not impact the public api of any crate.

Either is used for crate interchange in some ways, as part of the public api. Then it has ecosystem implications if we go from version 1 to 2, and crates need to update together to be compatible, some even are forced to bump from 1 to 2 themselves. At this point, I don't see evidence that we have enough to fix in either 2.0, for it to be worth it.

nvzqz

comment created time in 4 months

Pull request review commentrust-ndarray/ndarray

Implement arithmetic ops on more combinations of types

 pub type Ixs = isize; /// are supported (scalar can be on either the left or right side, but /// `ScalarOperand` docs has the detailed condtions). ///-/// - `&A @ K` or `K @ &A` which produces a new `Array`-/// - `B @ K` or `K @ B` which consumes `B`, updates it with the result and returns it-/// - `C @= K` which performs an arithmetic operation in place+/// - `&A @ K`, `V @ K`, `K @ &A`, or `K @ V` which produces a new `Array`+/// - `O @ K` or `K @ O` which consumes `O`, updates it with the result and returns it+/// - `M @= K` which performs an arithmetic operation in place /// /// ### Unary Operators ///-/// Let `A` be an array or view of any kind. Let `B` be an array with owned-/// storage (either `Array` or `ArcArray`). The following operands are supported-/// for an arbitrary unary operator denoted by `@` (it can be `-` or `!`).+/// Let `A` be an array or view of any kind. Let `O` be an array with owned+/// storage (either `Array` or `ArcArray`). Let `V` be an `ArrayView`. The+/// following operands are supported for an arbitrary unary operator denoted by+/// `@` (it can be `-` or `!`). ///-/// - `@&A` which produces a new `Array`-/// - `@B` which consumes `B`, updates it with the result, and returns it+/// - `@&A` or `@V` which produces a new `Array`+/// - `@O` which consumes `O`, updates it with the result, and returns it

Thanks for updating this, even if it's a draft PR or whatever, it makes it easy to discuss changes :)

jturner314

comment created time in 4 months

Pull request review commentrust-ndarray/ndarray

Implement arithmetic ops on more combinations of types

 impl<'a, S, D> $trt<&'a ArrayBase<S, D>> for $scalar         })     } }++/// Perform elementwise+/// between the scalar `self` and array `rhs`,+/// and return the result as a new `Array`.

I would especially discourage these impl blocks. We have to spend a lot of impl blocks on the arithmetic ops with scalars on the left hand side. Part of me want to just remove everything with left hand side scalars, because it can never(?) be properly general because of how we need to express it as an impl .. for $scalar (for a specific single type).

jturner314

comment created time in 4 months

Pull request review commentrust-ndarray/ndarray

Implement arithmetic ops on more combinations of types

 impl<'a, S, D> $trt<&'a ArrayBase<S, D>> for $scalar         })     } }++/// Perform elementwise+/// between the scalar `self` and array `rhs`,+/// and return the result as a new `Array`.

Not important, but just something I saw. Allegedly this doc is not visible in rustdoc, but that comment may be outdated now(!). then we want that #[doc=$doc] back to make a complete sentence.

jturner314

comment created time in 4 months

pull request commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

Cool, you've done a lot of exploration. This is r=me when you think it is ready

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 impl<T: fmt::Debug> fmt::Debug for Difference<'_, T> { /// [`BTreeSet`]: struct.BTreeSet.html /// [`symmetric_difference`]: struct.BTreeSet.html#method.symmetric_difference #[stable(feature = "rust1", since = "1.0.0")]-pub struct SymmetricDifference<'a, T: 'a> {-    a: Peekable<Iter<'a, T>>,-    b: Peekable<Iter<'a, T>>,-}+pub struct SymmetricDifference<'a, T: 'a>(MergeIterInner<Iter<'a, T>>);  #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for SymmetricDifference<'_, T> {     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        f.debug_tuple("SymmetricDifference")-         .field(&self.a)-         .field(&self.b)-         .finish()+        f.debug_tuple("SymmetricDifference").field(&self.0).finish()

stringify! has no smarts, but at least it look like an indent and a refactoring tool could potentially handle renames.

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {      fn next(&mut self) -> Option<&'a T> {         loop {-            match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {-                Less => return self.a.next(),-                Equal => {-                    self.a.next();-                    self.b.next();-                }-                Greater => return self.b.next(),+            match self.0.nexts() {+                (None, None) => return None,+                (Some(item), None) => return Some(item),+                (None, Some(item)) => return Some(item),

Option::xor is new. I'm mildly excited because it looks like it fits here

ssomers

comment created time in 4 months

push eventrust-ndarray/ndarray

Jim Turner

commit sha 08964fdccfcd94163cb82b5b3130c3a491f3c939

Implement fold for IndicesIter This improves performance somewhat.

view details

Jim Turner

commit sha 76b7eaff96de0bdb5eb9a5579a44ff502253d557

Fix bugs and improve test for IndicesIter::fold

view details

bluss

commit sha 1a0725894835433fb34d929df85354a81418c8ce

Merge pull request #733 from jturner314/impl-fold-for-indicesiter Implement fold for IndicesIter

view details

push time in 4 months

PR merged rust-ndarray/ndarray

Implement fold for IndicesIter performance

This improves performance somewhat.

#728 made me curious about this. On my machine, this PR improves the norm_f32 benchmark by 8%, the norm_f64 benchmark by 9%, and the uniform_f32 benchmark by 2%. I haven't compared it to #728 directly for improving ndarray-rand performance; I would guess that #728 would be better. Regardless, this PR is an improvement to IndicesIter.

+54 -0

2 comments

1 changed file

jturner314

pr closed time in 4 months

pull request commentrust-ndarray/ndarray

Implement fold for IndicesIter

Thanks for this, I'll go ahead and merge

jturner314

comment created time in 4 months

pull request commentrust-ndarray/ndarray

Implement arithmetic ops on more combinations of types

Treating ArrayView and &ArrayBase same seems sensible. So I'd say it would be great if those could be treated in the same impl.

jturner314

comment created time in 4 months

pull request commentrust-ndarray/ndarray

Implement arithmetic ops on more combinations of types

The summary issue is #699 where we coordinate work on this.

I'd investigate what's the total count of arith ops impl methods before and after this change? What's the clean build time of the ndarray crate before and after?

One suggested strategy for improving compilation time given in #699 is to have fewer impl blocks that cover more cases. We can use marker traits if needed. (We can use https://doc.rust-lang.org/nightly/std/array/trait.LengthAtMost32.html as inspiration in a way - it's a marker that allows each other array trait impl to be written as one impl instead of 33 pieces.)

I think this should be seen in context of #699. Here we add more impls that do the same "clone whole array and then do the op", which is something we want to fix.

jturner314

comment created time in 4 months

pull request commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

Looks good to me, I only had style questions

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 impl<'a, T: Ord> Iterator for SymmetricDifference<'a, T> {      fn next(&mut self) -> Option<&'a T> {         loop {-            match cmp_opt(self.a.peek(), self.b.peek(), Greater, Less) {-                Less => return self.a.next(),-                Equal => {-                    self.a.next();-                    self.b.next();-                }-                Greater => return self.b.next(),+            match self.0.nexts() {+                (None, None) => return None,+                (Some(item), None) => return Some(item),+                (None, Some(item)) => return Some(item),

This can be combined into one branch (Some(item), None) | (None, Some(item)) =>

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 pub struct Range<'a, T: 'a> {     iter: btree_map::Range<'a, T, ()>, } +/// Core of SymmetricDifference and Union.+/// More efficient than btree.map.MergeIter,+/// and crucially for SymmetricDifference, nexts() reports on both sides.+#[derive(Clone)]+struct MergeIterInner<I>+where+    I: Iterator,+    I::Item: Copy,+{+    a: I,+    b: I,+    peeked: Option<MergeIterPeeked<I>>,+}++#[derive(Copy, Clone, Debug)]+enum MergeIterPeeked<I>+where+    I: Iterator,+{+    A(I::Item),+    B(I::Item),+}++impl<I> MergeIterInner<I>+where+    I: ExactSizeIterator + FusedIterator,+    I::Item: Copy + Ord,+{+    fn new(a: I, b: I) -> Self {+        MergeIterInner { a, b, peeked: None }+    }++    fn nexts(&mut self) -> (Option<I::Item>, Option<I::Item>) {+        let mut a_next = match self.peeked {+            Some(MergeIterPeeked::A(next)) => Some(next),+            _ => self.a.next(),+        };+        let mut b_next = match self.peeked {+            Some(MergeIterPeeked::B(next)) => Some(next),+            _ => self.b.next(),+        };+        let ord = match (a_next, b_next) {+            (None, None) => Equal,+            (_, None) => Less,+            (None, _) => Greater,+            (Some(a1), Some(b1)) => a1.cmp(&b1),+        };+        self.peeked = match ord {+            Less => b_next.take().map(MergeIterPeeked::B),+            Equal => None,+            Greater => a_next.take().map(MergeIterPeeked::A),+        };

This code then makes me wonder if there is any benefit to splitting peeked into two fields, Option<A::Item> and enum Peeked { A, B }. Just an idle curiosity.

ssomers

comment created time in 4 months

pull request commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

Ok, so now I abandon the other PR and we focus on this one, that sounds good?

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 pub struct Range<'a, T: 'a> {     iter: btree_map::Range<'a, T, ()>, } +/// Core of SymmetricDifference and Union.+/// More efficient than btree.map.MergeIter,+/// and crucially for SymmetricDifference, nexts() reports on both sides.+#[derive(Clone)]+struct MergeIterInner<I>+where+    I: Iterator,+    I::Item: Copy,

The where style in the new code does not match the existing code in the file.

What do we normally do? rustfmt? I'd prefer to keep the existing style, we keep the same file consistent.

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 impl<T: fmt::Debug> fmt::Debug for Difference<'_, T> { /// [`BTreeSet`]: struct.BTreeSet.html /// [`symmetric_difference`]: struct.BTreeSet.html#method.symmetric_difference #[stable(feature = "rust1", since = "1.0.0")]-pub struct SymmetricDifference<'a, T: 'a> {-    a: Peekable<Iter<'a, T>>,-    b: Peekable<Iter<'a, T>>,-}+pub struct SymmetricDifference<'a, T: 'a>(MergeIterInner<Iter<'a, T>>);  #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for SymmetricDifference<'_, T> {     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        f.debug_tuple("SymmetricDifference")-         .field(&self.a)-         .field(&self.b)-         .finish()+        f.debug_tuple("SymmetricDifference").field(&self.0).finish()

I asked on the internals forum whether we could prefer the style f.debug_tuple(stringify!(SymmetricDifference)) when we hard-code the struct/enum name. I still prefer that style, but on the forum it got a lukewarm response.

ssomers

comment created time in 4 months

Pull request review commentrust-lang/rust

BTreeSet symmetric_difference & union optimized

 enum IntersectionInner<'a, T: 'a> { #[stable(feature = "collection_debug", since = "1.17.0")] impl<T: fmt::Debug> fmt::Debug for Intersection<'_, T> {     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {-        match &self.inner {-            IntersectionInner::Stitch {-                a,-                b,-            } => f-                .debug_tuple("Intersection")-                .field(&a)-                .field(&b)-                .finish(),-            IntersectionInner::Search {-                small_iter,-                large_set: _,-            } => f.debug_tuple("Intersection").field(&small_iter).finish(),-            IntersectionInner::Answer(answer) => {-                f.debug_tuple("Intersection").field(&answer).finish()-            }-        }+        f.debug_tuple("Intersection").field(&self.inner).finish()

(I'm not proposing any change.) I can't see or remember why these don't use derive(Debug), anyone know? It looks like implementation including trait bounds matches what the derive would produce.

ssomers

comment created time in 4 months

push eventbluss/either

Kamat, Trivikram

commit sha 9da7f3f1cc321289542341060c8df4e057c4feb1

fix: allow bare_trait_objects Fixes: https://github.com/bluss/either/issues/41

view details

bluss

commit sha bdef374df0f39ef81a5c524df2127e1b56a8601d

Merge pull request #42 from trivikr/allow_bare_trait_objects fix: allow bare_trait_objects

view details

push time in 4 months

PR merged bluss/either

fix: allow bare_trait_objects

Fixes: https://github.com/bluss/either/issues/41

+1 -0

1 comment

1 changed file

trivikr

pr closed time in 4 months

issue closedbluss/either

rustc warning: trait objects without an explicit `dyn` are deprecated

Following warning is shown while using either@1.5.3 is used as a dependency:

warning: trait objects without an explicit `dyn` are deprecated
   --> /home/trivikr/.cargo/registry/src/github.com-1ecc6299db9ec823/either-1.5.3/src/lib.rs:839:32
    |
839 |     fn cause(&self) -> Option<&Error> {
    |                                ^^^^^ help: use `dyn`: `dyn Error`
    |
    = note: #[warn(bare_trait_objects)] on by default

The code which needs to be updated: https://github.com/bluss/either/blob/cd15a341118b5af765450dcb6380c6dee17ed0f2/src/lib.rs#L839-L841

closed time in 4 months

trivikr

pull request commentbluss/either

fix: allow bare_trait_objects

Thanks!

trivikr

comment created time in 4 months

more