Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug implementation for Smartcore structs in notebooks #1

Open
Mec-iS opened this issue Oct 18, 2022 · 0 comments
Open

Debug implementation for Smartcore structs in notebooks #1

Mec-iS opened this issue Oct 18, 2022 · 0 comments

Comments

@Mec-iS
Copy link
Contributor

Mec-iS commented Oct 18, 2022

Common structs should have implemented their own evcxr_display function in Debug trait to be visualized correctly in Notebooks (as HTML).

For example as found here for List:

use std::fmt::Debug;
pub struct List<T>(Vec<T>);
impl<T: Debug> List<T> {
    pub fn evcxr_display(&self) {
        let mut html = String::new();
        
        html.push_str("<ol>");
        
        for item in &self.0 {
            html.push_str(&format!("<li>{:?}</li>", item));
        }
        
        html.push_str("</ol>");
        println!("EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT", html);
    }
}

Different issues for this can be opened in main smartcore repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant