Сергей
всё равно линтер будет ругаться
Абэ-но Сэймэй
линтер можно заткнуть)
Berkus
на что?
на r# не любит он это дело
Сергей
на кривые имена, если их использоать
вафля
на r# не любит он это дело
Странно, не замечал такого 🤔 Хотя может я просто r# не использовал
Социальная Шизофрения
pub async fn start(&self) -> Result<(), Error> { let mut stream = self.api.stream(); while let Some(update) = stream.next().await { let update = update?; if let UpdateKind::Message(message) = update.kind { if self.admins.contains(&message.from.id.into()) { self.api .send( message .text_reply(format!( "Hello admin, [{}](tg://user?id={})", message.from.first_name, message.from.id, )) .parse_mode(ParseMode::Markdown), ) .await?; tokio::spawn(async { self.admin_handler.handle(message).await; // TODO: add logging error }); } } } Ok(()) }
Социальная Шизофрения
cannot infer an appropriate lifetime
Социальная Шизофрения
self
Julian 🏳️‍🌈
соболезную
вафля
cannot infer an appropriate lifetime
это точно не вся ошибка, по такому куску это гадание на кофейной гуще
вафля
Потому что использовать нужно teloxide 😊
Я ждал этого. [вы стриггерили Hirrolot'а]
Hirrolot
Я ждал этого. [вы стриггерили Hirrolot'а]
Самое забавное то, что в teloxide бы конкретно на self такого не произошло, потому что там self без ссылки
Hirrolot
Да!
Hirrolot
Так, теперь у меня вопрос. Мой макрос принимает такую грамматику: { ident "of" path => expr }+ Как это с syn синтаксически разобрать?
Социальная Шизофрения
вафля
Да!
Записывайтесь на обмазывание Arc<>ами девочки 💅
Hirrolot
хахахаха
И руками разбирать UpdateKind, скорее всего, не придётся
вафля
И руками разбирать UpdateKind, скорее всего, не придётся
мне нравится твоё "скорее всего"
Социальная Шизофрения
это точно не вся ошибка, по такому куску это гадание на кофейной гуще
error: cannot infer an appropriate lifetime --> src/handler/general.rs:54:24 | 54 | pub async fn start(&self) -> Result<(), Error> { | ^^^^^ | | | data with this lifetime... | ...is captured here... ... 70 | tokio::spawn(async { | ------------ ...and required to be `'static` by this
Hirrolot
хахахаха
Я не шучу.
вафля
используй self и move
Hirrolot
используй self и move
Ну вот зачем ты ему сказал
вафля
Если тебе всё же очень хочеться ссылок — Arc в помощь (tip: можно делать self: Arc<Type>)
вафля
Ну вот зачем ты ему сказал
Чтобы он помучался подольше
Социальная Шизофрения
вафля
спасибо
обращайся
Andrey
Мне руками текст дербанить, да?
Ну так syn же, руками значит
Hirrolot
Прям текст
Hirrolot
Стринг
Andrey
А, ну нет конечно
Hirrolot
Что делать?)
Andrey
Что делать?)
Что-то похожее на пример в доке по syn: https://docs.rs/syn/1.0.36/syn/parse/index.html
Социальная Шизофрения
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... --> src/handler/general.rs:14:6 | 14 | impl<'a, 'b> GeneralHandler<'a, 'b> { | ^^ note: ...so that the expression is assignable --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ = note: expected `std::sync::Arc<handler::general::GeneralHandler<'_, '_>>` found `std::sync::Arc<handler::general::GeneralHandler<'a, 'b>>` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds --> src/handler/general.rs:76:25 | 76 | tokio::spawn(async move { | ^^^^^^^^^^^^ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... --> src/handler/general.rs:14:6 | 14 | impl<'a, 'b> GeneralHandler<'a, 'b> { | ^^ note: ...so that the expression is assignable --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ = note: expected `std::sync::Arc<handler::general::GeneralHandler<'_, '_>>` found `std::sync::Arc<handler::general::GeneralHandler<'a, 'b>>` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds --> src/handler/general.rs:76:25 | 76 | tokio::spawn(async move { | ^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. error: could not compile `argus`. To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. error: build failed Process finished with exit code 101
человек формата йоу
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... --> src/handler/general.rs:14:6 | 14 | impl<'a, 'b> GeneralHandler<'a, 'b> { | ^^ note: ...so that the expression is assignable --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ = note: expected `std::sync::Arc<handler::general::GeneralHandler<'_, '_>>` found `std::sync::Arc<handler::general::GeneralHandler<'a, 'b>>` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds --> src/handler/general.rs:76:25 | 76 | tokio::spawn(async move { | ^^^^^^^^^^^^ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... --> src/handler/general.rs:14:6 | 14 | impl<'a, 'b> GeneralHandler<'a, 'b> { | ^^ note: ...so that the expression is assignable --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ = note: expected `std::sync::Arc<handler::general::GeneralHandler<'_, '_>>` found `std::sync::Arc<handler::general::GeneralHandler<'a, 'b>>` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds --> src/handler/general.rs:76:25 | 76 | tokio::spawn(async move { | ^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. error: could not compile `argus`. To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. error: build failed Process finished with exit code 101
клонируй self и уже копию используй в новой таске
Hirrolot
error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... --> src/handler/general.rs:14:6 | 14 | impl<'a, 'b> GeneralHandler<'a, 'b> { | ^^ note: ...so that the expression is assignable --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ = note: expected `std::sync::Arc<handler::general::GeneralHandler<'_, '_>>` found `std::sync::Arc<handler::general::GeneralHandler<'a, 'b>>` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds --> src/handler/general.rs:76:25 | 76 | tokio::spawn(async move { | ^^^^^^^^^^^^ error[E0495]: cannot infer an appropriate lifetime due to conflicting requirements --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined on the impl at 14:6... --> src/handler/general.rs:14:6 | 14 | impl<'a, 'b> GeneralHandler<'a, 'b> { | ^^ note: ...so that the expression is assignable --> src/handler/general.rs:59:24 | 59 | pub async fn start(self: Arc<Self>) -> Result<(), Error> { | ^^^^ = note: expected `std::sync::Arc<handler::general::GeneralHandler<'_, '_>>` found `std::sync::Arc<handler::general::GeneralHandler<'a, 'b>>` = note: but, the lifetime must be valid for the static lifetime... note: ...so that the type `impl std::future::Future` will meet its required lifetime bounds --> src/handler/general.rs:76:25 | 76 | tokio::spawn(async move { | ^^^^^^^^^^^^ error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. error: could not compile `argus`. To learn more, run the command again with --verbose. warning: build failed, waiting for other jobs to finish... error: aborting due to previous error For more information about this error, try `rustc --explain E0495`. error: build failed Process finished with exit code 101
Почему бы тебе не переписать это на teloxide? Там ссылок почти не берут, не придётся разруливать такие конфликты в 90% случаев
Andrey
клонируй self и уже копию используй в новой таске
Вряд ли это избавит его Self от лайфтаймов
человек формата йоу
Смена либы не поможет, если нет понимания
поможет, код работать будет)
Vetro
А потом на чем-то другом застрянет, а не на лайфтаймах Self
человек формата йоу
А потом на чем-то другом застрянет, а не на лайфтаймах Self
будем решать проблемы по мере их появления
Alex
Нубский вопрос. Если я хочу преобразовать Option в Result так чтобы None превратилось в Error, то есть метод ok_or(). А если я хочу наоборот, проверить на None, т.е. чтобы Some превратилось в Error, а None, ну пусть в Ok(()), как наиболее канонично написать однострочник? Чтобы смысл не терялся. Нет какого-то "парного" метода?
Cuno
> Вы пытаетесь открыть публикацию, написанную пользователем vdsina_m, однако, публикация скрыта в черновики (самим автором или НЛО)
Василий
Writing a file system from scratch in Rust · carlosgaldino https://blog.carlosgaldino.com/writing-a-file-system-from-scratch-in-rust.html
Alex
Парного метода нет, мой PR в std отклонили. Я пишу либу с екстеншеном под это, но надо там дописать документацию и т.д. Можешь посмотреть как там реализованно: https://github.com/WaffleLapkin/err_or/blob/master/src/lib.rs
Я так и думал.. :( Я сейчас делаю примерно так: must_be_none.map_or(Ok(()), |_| Err(Error::BadArgument))?; Но смысл теряется, с первого взгляда непонятно, что тут имеется ввиду :(
Anonymous
Какой скриптовый язык хорошо дружит с Rust? Хочу сделать ручные сценарии для приложения, но не могу определиться. Говорили про Python, но есть же другие варианты?
Julian 🏳️‍🌈
AssemblyScript
Anonymous
Ага
Berkus
ну и есть пачка прямо растоспецифичных e-языков
Berkus
https://lib.rs/keywords/language листай ищи, там много
Berkus
mech, duon, duckscript...
Anonymous
mech, duon, duckscript...
Спасибо, нашёл подходящий
Hirrolot
Почему он на синтаксис ругается?
Hirrolot
Денис
ты шутишь?
Hirrolot
?
Денис
он же тебе явно говорит ошибку
Денис
Hirrolot
А как исправить?
xor eax, eax
Можно попробовать просто ()
Berkus
баланс скобочек верни!
вафля
в растокоде все [], {}, () должны быть парными
Денис
А как исправить?
https://docs.rs/syn/1.0.36/syn/token/struct.Brace.html#method.surround и подобное
Денис
либо же сначала подготовить тело, а потом сделать quote!( ... move { #body } )
Hirrolot
Hirrolot
Вот так решил
Nuxs🏴‍☠️
https://goo.su/1sSb строка 65, всё дело в функции service. В функции service нужно как-то использовать бота(добавлять записи, просматривать действия и всё такое), но эта функция должна быть типа async fn service(req: Request<Body>) -> Result<Response<Body>, Infallible>, так как иначе её не примет функция service_fn. Целый день на эту дрянь потратил, я в тупике
Денис
{{ -> {
Hirrolot
Неплохо