cargo run
with the edited source in ".cargo/registry/src/github.com-1ecc6299db9ec823/ispell-0.3.0/src/spell_checker.rs" for example ?
crate = { git = "https://my-repo", branch = "something" }
and then create a merge request. Or just report the problem and do something else in the meantime ‒ some crate authors are super fast and often a fixed version gets published in less than a day.
hello
I need help with juniper
I've copied this file https://github.com/graphql-rust/juniper/blob/master/juniper/src/tests/model.rs
to my project
But when I cargo run, I get:
error[E0432]: unresolved import `InputValue`
--> src/model.rs:5:10
|
5 | #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
| ^^^^^^^^^^^ no `InputValue` in the root
I added InputValue to main.rs, then compiler wanted another uses. So even with this in main.rs:
use juniper::InputValue;
use juniper::Value;
use juniper::ToInputValue;
use juniper::FromInputValue;
use juniper::Executor;
I got:
error[E0365]: `InputValue` is private, and cannot be reexported
--> src/model.rs:5:10
|
5 | #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
| ^^^^^^^^^^^ reexport of private `InputValue`
|
= note: consider declaring type or module `InputValue` with `pub`
error[E0365]: `Value` is private, and cannot be reexported
--> src/model.rs:5:10
|
5 | #[derive(GraphQLEnum, Copy, Clone, Eq, PartialEq, Debug)]
| ^^^^^^^^^^^ reexport of private `Value`
|
= note: consider declaring type or module `Value` with `pub`
and so on...
(impl FnMut() -> i32) + 'a
?
impl FnMut() -> i32 + 'a
impl FnMut() -> (i32 + 'a)
Copy
default @gnzlbg
mve*
mean?
*thing
, not just thing
for
for<'b>
somewhere
fn bar<'a>(y: &'a i32) -> impl FnMut()->i32 + 'a {
move || *y
}
fn main() {
let x = 42;
println!("{}", bar(&x)());
}
i32 + 'a
impl 'a + FnMut() -> i32
'a
, not only the y
with the 'a
lifetime
y
in the closure
'a
, then saying that the closure also has the lifetime 'a
is a good approximation
let text_area: gtk::TextView = builder.get_object("output_label").unwrap()
output of let mut out = 1 + 2
for example?
gtk::Label
instead of gtk::TextView
output_label.set_label(&format!("{}", out))
use gtk::Label;
use gtk::prelude::*;
let label = Label::new(None);
let text =
r#"Go to the
<a href="http://www.gtk.org" title="<i>Our</i> website">
GTK+ website</a> for more..."#;
label.set_markup(text);
LabelExt::set_label
label.set_label(&format!("{}", out));
let mut out = gtkentrylabel.get_text();
?
mut
error[E0423]: expected value, found struct `gtk::Entry`
--> src/main.rs:19:22
|
19 | let text_entry = gtk::Entry = builder.get_object("text_enter").unwrap();
| ^^^^^^^^^^ did you mean `gtk::Entry { /* fields */ }`?
=
should have been :
, no?
let get_text_from_entry = atext_entry.get_text();
to i32
std::option::Option<std::string::String>
let value: i32 = text.unwrap_or("").parse()?;
let get_text_from_entry = atext_entry.get_text();
let anum: i32 = get_text_from_entry.unwrap_or("").parse()?;
let anum: i32 = get_text_from_entry.unwrap_or("").parse()?;
| ------------------------------------------
| |
| cannot use the `?` operator in a function that returns `()`
| in this macro invocation
error[E0308]: mismatched types
--> src/main.rs:26:55
|
26 | let anum: i32 = get_text_from_entry.unwrap_or("").parse()?;
| ^^ expected struct `std::string::String`, found reference
|
= note: expected type `std::string::String`
found type `&'static str`
= help: here are some functions which might fulfill your needs:
- .escape_debug()
- .escape_default()
- .escape_unicode()
- .to_ascii_lowercase()
- .to_ascii_uppercase()
error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
--> src/main.rs:26:25
|
26 | let anum: i32 = get_text_from_entry.unwrap_or("").parse()?;
| ------------------------------------------
| |
| cannot use the `?` operator in a function that returns `()`
| in this macro invocation
|
= help: the trait `std::ops::Try` is not implemented for `()`
= note: required by `std::ops::Try::from_erro
.unwrap_or("".to_string())
rror[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
--> src/main.rs:26:25
|
26 | let anum: i32 = get_text_from_entry.unwrap_or("".to_string()).parse()?;
| ------------------------------------------------------
| |
| cannot use the `?` operator in a function that returns `()`
| in this macro invocation
|
that's full code
extern crate gtk;
use gtk::prelude::*;
use gtk::{Label,Button, Window, WindowType};
use gtk::Entry;
//use gtk::LabelExt;
fn main() {
if gtk::init().is_err() {
println!("Failed to initialize GTK.");
return;
}
let glade_src = include_str!("ui.glade");
let builder = gtk::Builder::new_from_string(glade_src);
let button: gtk::Button = builder.get_object("proceed").unwrap();
let window: gtk::Window = builder.get_object("window1").unwrap();
let text_area: gtk::Label = builder.get_object("output_label").unwrap();
let atext_entry: gtk::Entry = builder.get_object("anum").unwrap();
let btext_entry: gtk::Entry = builder.get_object("bnu").unwrap();
let ctext_entry: gtk::Entry = builder.get_object("cnum").unwrap();
button.connect_clicked(move |_| {
println!("Button pressed");
let get_text_from_entry = atext_entry.get_text();
let anum: i32 = get_text_from_entry.unwrap_or("".to_string()).parse()?;
});
window.show_all();
gtk::main();
}
That's full error
error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`)
--> src/main.rs:26:25
|
26 | let anum: i32 = get_text_from_entry.unwrap_or("".to_string()).parse()?;
| ------------------------------------------------------
| |
| cannot use the `?` operator in a function that returns `()`
| in this macro invocation
|
= help: the trait `std::ops::Try` is not implemented for `()`
= note: required by `std::ops::Try::from_error`
error: aborting due to previous error
error: Could not compile `runo_gtk`.
unwrap
s right and left with such ease.
?
operator is the most ergonomic one usually, but it needs the caller to expect a Result
.
Result<i32, whatever_error_type_you_need>
and wrap it in a closure that does something to the result.
whatever_error
is important?
parse
of an integer, it can be ParseIntError