Implement `Debug` for `ViewRepr`

Aperta
#1,057 6 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
rust
Ambito
data

Direzione di ricerca

Start by locating the ViewRepr definition and its existing trait implementations. Implement the requested Debug support, then verify that the generic example in the issue compiles and that formatting a view works as shown.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Basically if you ever try to write a function that is generic over any array subtype (ArrayView, Array etc), then you aren't able to use debug features, because ViewRepr doesn't implement Debug:

use ndarray::*;
use core::fmt::Debug;
fn print_arr<S: Data<Elem=T> + Debug, T: Debug>(array: &ArrayBase<S, Ix1>){
    dbg!(array);
}
fn main(){
    let arr = array![1, 2, 3];
    print_arr(&arr);
    print_arr(&arr.view());
}
    print_arr(&arr.view());
              ^^^^^^^^^^^ `ViewRepr<&{integer}>` cannot be formatted using `{:?}` because it doesn't implement `Debug`
`ViewRepr<&{integer}>` doesn't implement `Debug`
help: the trait `Debug` is not implemented for `ViewRepr<&{integer}>`

Here's a playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9754536345631a70374f14d3703050cf.

Happy to write a PR but it looks like PR review is pretty slow at the moment so I'll hold off until this issue has been approved.

Lingua principale
Rust
Stelle
4.3k
Fork
391
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-ndarray/ndarray

Tutte le issue di rust-ndarray/ndarray

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.