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

[Documentation] Example of the code for Rust does not compile #74

Open
ghost opened this issue Jul 17, 2020 · 0 comments
Open

[Documentation] Example of the code for Rust does not compile #74

ghost opened this issue Jul 17, 2020 · 0 comments

Comments

@ghost
Copy link

ghost commented Jul 17, 2020

From https://vislyhq.github.io/stretch/docs/rust/
Example:

use stretch::{style::*, node::{Node, Stretch}, geometry::Size};
 
fn main() {
  let stretch = Stretch::new();
  
  let mut node = stretch.new_node(Style { ..Default::default() }, vec![
    stretch.new_node(Style {
      size: Size { 
          width: Dimension::Points(100.0), 
          height: Dimension::Points(100.0),
      },
      ..Default::default()
    }).unwrap()
  ]).unwrap();
  
  stretch.compute_layout(node, Size::undefined()).unwrap();
  
  // Mutate node
  stretch.set_style(node, Style {
    size: Size { 
        width: Dimension::Points(100.0), 
        height: Dimension::Points(100.0),
    },
    ..Default::default()
  }).unwrap();
 
  // This call will return partially cached results
  stretch.compute_layout(node, Size::undefined()).unwrap();
}

Message I've got:

warning: unused import: `Node`
 --> src/main.rs:1:32
  |
1 | use stretch::{style::*, node::{Node, Stretch}, geometry::Size};
  |                                ^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0061]: this function takes 2 arguments but 1 argument was supplied
  --> src/main.rs:7:13
   |
7  |       stretch.new_node(Style {
   |  _____________^^^^^^^^_-
   | |             |
   | |             expected 2 arguments
8  | |       size: Size { 
9  | |           width: Dimension::Points(100.0), 
10 | |           height: Dimension::Points(100.0),
11 | |       },
12 | |       ..Default::default()
13 | |     }).unwrap()
   | |_____- supplied 1 argument

error: aborting due to previous error; 1 warning emitted

For more information about this error, try `rustc --explain E0061`.
error: could not compile `hello_stretch`.

To learn more, run the command again with --verbose.

OS: Linux 4.4.0-19041-Microsoft #1-Microsoft Fri Dec 06 14:06:00 PST 2019 x86_64 x86_64 x86_64 GNU/Linux
Rust version: 1.45.0

EDIT. My proposal to fix it #75

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

0 participants