schell / schell/wgsl-rs

impl `MulAssign` (and friends) for `VecN<T>` and `MatNxMf`

Open
#162 0 comments 0 reactions 0 assignees View on GitHub
enhancement P1 wgsl-std
Dominant language
Rust
Stars
61
Forks
4
Avg merge
1d 21h
Merged PRs (30d)
9

Description

The [WGSL spec](https://www.w3.org/TR/2026/CRD-WGSL-20260825/#compound-assignment) allows for "compound assignments", this lets you do things like:

```wgsl
var v = vec2f(0.,0.);
v *= 2.;
var m = mat2x2f(v,v);
m *= 2.;
```

However this is currently not supported in wgsl-rs:

```
error[E0368]: binary assignment operation `*=` cannot be applied to type `wgsl_rs::std::Vec2`
--> crates/app/src/my_shader.rs:11:9
|
11 | v *= 2.;
| -^^^^^^
| |
| cannot use `*=` on type `wgsl_rs::std::Vec2`
|
note: `wgsl_rs::std::Vec2` does not implement `std::ops::MulAssign<{float}>`
--> vendor/wgsl-rs/crates/wgsl-rs/src/std/vector.rs:17:1

error[E0368]: binary assignment operation `*=` cannot be applied to type `Mat2x2f`
--> crates/app/src/my_shader.rs:13:9
|
13 | m *= 2.;
| -^^^^^^
| |
| cannot use `*=` on type `Mat2x2f`
|
note: `Mat2x2f` does not implement `std::ops::MulAssign<{float}>
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with vendor/wgsl-rs/crates/wgsl-rs/src/std/vector.rs and locate the corresponding MatNxMf definitions. Use crates/app/src/my_shader.rs as the reproduction entry point, then verify that the requested compound assignments compile for the vector and matrix types covered by the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.