Implement `Debug` for `ViewRepr`

Đang mở
#1,057 6 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
rust
Lĩnh vực
data

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Rust
Star
4.3k
Fork
391
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của rust-ndarray/ndarray

Tất cả issue của rust-ndarray/ndarray

Issue tương tự

Thêm issue về Rust

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.