note: the method `and_then` exists but the following trait bounds were not satisfied: `futures::stream::Fold<futures::stream::SplitStream<to
kio_core::io::Framed<tokio_core::net::TcpStream, tokio_websocket::codec::WSCodec>>, [closure@examples/autobahn-client.rs:29:31: 38:14], futures::
FutureResult<futures::MapErr<futures::Map<futures::sink::Send<futures::stream::SplitSink<tokio_core::io::Framed<tokio_core::net::TcpStream, tokio
_websocket::codec::WSCodec>>>, [closure@examples/autobahn-client.rs:33:35: 33:55]>, [closure@examples/autobahn-client.rs:34:51: 34:57]>, _>, futu
res::stream::SplitSink<tokio_core::io::Framed<tokio_core::net::TcpStream, tokio_websocket::codec::WSCodec>>> : futures::Stream`, `futures::stream
::Fold<futures::stream::SplitStream<tokio_core::io::Framed<tokio_core::net::TcpStream, tokio_websocket::codec::WSCodec>>, [closure@examples/autob
ahn-client.rs:29:31: 38:14], futures::FutureResult<futures::MapErr<futures::Map<futures::sink::Send<futures::stream::SplitSink<tokio_core::io::Fr
amed<tokio_core::net::TcpStream, tokio_websocket::codec::WSCodec>>>, [closure@examples/autobahn-client.rs:33:35: 33:55]>, [closure@examples/autob
ahn-client.rs:34:51: 34:57]>, _>, futures::stream::SplitSink<tokio_core::io::Framed<tokio_core::net::TcpStream, tokio_websocket::codec::WSCodec>>
> : futures::Future`
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170213/032155.html
внезапно овнершип в свифте
они там давно с ним возятся. У них ARC, т.е. подсчет ссылок в рантайме. А с ownership большую часть подсчетов можно либо выкинуть совсем, либо вкомпилить в код программы заранее. Но сразу не хотели его делать, тк боялись, что язык неудобный получится.
Пусть делают :+1:
C/C++ to Rust Transpiler https://github.com/NishanthSpShetty/crust
We were able to cover about 95% of our code through unit tests.
impl <'a>ExonumJson for HashMap<&'a str, u32> {
fn deserialize_field<B>(value: &Value, buffer: &mut B, from: Offset, to: Offset) -> Result<(), Box<Error>>
where B: WriteBufferWrapper
{
Ok(Value::Null)
}
fn serialize_field(&self) -> Result<Value, Box<Error>> {
Ok(Value::String("ser".to_string()))
}
}
Could you help me with some error
error[E0619]: the type of this value must be known in this context
about next code:
pub fn in_wallet_assets(&mut self, asset_list: Vec<Asset>) -> bool {
let assets_from_wallet = self.assets().clone();
!asset_list.into_iter().filter(move |a1| {
let condition: bool = assets_from_wallet.into_iter()
.filter(|a2| a2.hash_id() == a1.hash_id() && a2.amount() >= a1.amount())
.collect()
.is_empty();
!condition
}).collect().is_empty()
}
MAIN: [(id1, 10), (id2, 20), (id3, 30)]
INPUT: [(id1, 5), (id3, 30)]
EXPECTED: [(id1, 5), (id2, 20)]
Vec<u8>
перетворити в С інтерфейс.#[repr(C)]
, а функції як #[no_mangle]
вечер добрый. пытаюсь освоить rust + webassembly. есть кусок кода такой
let mut drag = Rc::new(false);
let mousedown_cb =
Closure::wrap(Box::new(|_event: MouseEvent| {
*Rc::get_mut(&mut drag).unwrap() = true;
}) as Box<dyn FnMut(MouseEvent)>);
event_target
.add_event_listener_with_callback("mousedown", mousedown_cb.as_ref().unchecked_ref())
.unwrap();
mousedown_cb.forget();
основная суть, мутировать "глобальную" переменную по ивенту от мыши. но rust пишет мне, что drag does not live long enough.
может кто-то помочь разобраться как заставить это работать? этот drag
далее будет использоваться в другой фунции чтобы отрисовывать картинку.
благодарю.
в общем, у меня получилось заставить работать его.
let drag = Rc::new(RefCell::new(false));
{
let d = drag.clone();
let mouseup_cb = Closure::wrap(Box::new(move |_event: MouseEvent| {
*d.borrow_mut() = false;
}) as Box<dyn FnMut(MouseEvent)>);
event_target
.add_event_listener_with_callback("mouseup", mouseup_cb.as_ref().unchecked_ref())
.unwrap();
mouseup_cb.forget();
}
{
let theta = theta.clone();
let phi = phi.clone();
let mousemove_cb = Closure::wrap(Box::new(move |event: MouseEvent| {
let d = drag.borrow();
if *d {
*theta.borrow_mut() += event.movement_x() as f32;
*phi.borrow_mut() += event.movement_y() as f32;
}
}) as Box<dyn FnMut(web_sys::MouseEvent)>);
event_target
.add_event_listener_with_callback("mousemove", mousemove_cb.as_ref().unchecked_ref())
.unwrap();
mousemove_cb.forget();
}
спасибо за помощь