外文分享

How to move a Vec<Box<dyn Trait>> Into Vec<Rc<RefCell<dyn Trait>>>

浪子不回头ぞ 提交于 2021-02-20 10:39:12
问题 I have a Vec<Box<dyn Trait>> as input, and I want to store its elements in a Vec<Rc<RefCell<dyn Trait>>> . What is the best way to do it? I tried with: use std::cell::RefCell; use std::rc::Rc; trait Trait {} fn main() { let mut source: Vec<Box<dyn Trait>> = Vec::new(); let mut dest: Vec<Rc<RefCell<dyn Trait>>> = Vec::new(); for s in source { let d = Rc::new(RefCell::new(s.as_ref())); dest.push(d); } } But I got the error: error[E0277]: the trait bound `&dyn Trait: Trait` is not satisfied -->

Getting CMake to find flex on Windows

混江龙づ霸主 提交于 2021-02-20 10:36:44
问题 I am trying to use flex on a project and I am trying to use CMake to link flex with my project. I found a FindFLEX.cmake online which I am using for this. You can find it here. This was supposed to be in CMake by default, but I dont think it was. My directory structure is as follows root ---src ---CMakeLists.txt ---cmake ---Modules ---FindFLEX.cmake ---build ---external ---flex - Where flex is installed ---bin ---flex.exe ---lib ---libfl.a My src/CMakeLists.txt is as follows cmake_minimum

Getting CMake to find flex on Windows

人盡茶涼 提交于 2021-02-20 10:36:11
问题 I am trying to use flex on a project and I am trying to use CMake to link flex with my project. I found a FindFLEX.cmake online which I am using for this. You can find it here. This was supposed to be in CMake by default, but I dont think it was. My directory structure is as follows root ---src ---CMakeLists.txt ---cmake ---Modules ---FindFLEX.cmake ---build ---external ---flex - Where flex is installed ---bin ---flex.exe ---lib ---libfl.a My src/CMakeLists.txt is as follows cmake_minimum

Edit Django admin logout template?

↘锁芯ラ 提交于 2021-02-20 10:31:53
问题 I want to make a very small change to the Django admin logout page. I know how to use templates to override the Django admin templates, so I have tried to do the same thing with the logout file. I have set up a new template at templates/registration/logged_out.html . The content of this file is as follows: {% extends "registration/logged_out.html" %} {% block content %} <p>Thanks for using the site.</p> <p><a href="../">Log in again</a></p> <p><a href="/">Return to the home page</a></p> {%

RX - rethrow an error in containing method

泄露秘密 提交于 2021-02-20 10:31:43
问题 I need to translate an error in an RX stream ( IObservable ) into an exception in the method that contains the subscription to the stream (because of this issue https://github.com/aspnet/SignalR/pull/1331 , Whereby errors arent serialised to clients.) Once this issue is fixed I will revert to handling error properly e.g. I have the following method public IObservable<StreamItem> LiveStream() { _mySvc.Start(); return _mySvc.ThingChanged(); } So I have tried to subscribe to the stream and

Edit Django admin logout template?

岁酱吖の 提交于 2021-02-20 10:31:05
问题 I want to make a very small change to the Django admin logout page. I know how to use templates to override the Django admin templates, so I have tried to do the same thing with the logout file. I have set up a new template at templates/registration/logged_out.html . The content of this file is as follows: {% extends "registration/logged_out.html" %} {% block content %} <p>Thanks for using the site.</p> <p><a href="../">Log in again</a></p> <p><a href="/">Return to the home page</a></p> {%

c#: Actions incomparable?

帅比萌擦擦* 提交于 2021-02-20 10:26:43
问题 I'm trying to compare two Actions. The comparison with == always returns false as does the Equals-method even though it's the same instance. My question is: Is it really not possible or am I doing it wrong? Cheers AC 回答1: You are doing it wrong. If I am to believe you, when you say "even though it's the same instance", then the following code executed through LINQPad tells me that you must be doing something wrong, or the "same instance" is incorrect: void Main() { Action a = () => Debug

Is there a way to know if Data Saver is enabled?

╄→尐↘猪︶ㄣ 提交于 2021-02-20 10:26:34
问题 Android 7.0 Nougat added Data Saver feature allowing users to restrict background data of certain apps (including push notifications). When Data Saver is ON, only the apps on the list found in Settings → Data Saver → Unrestricted data access are allowed to receive push notifications and execute background network calls. If Data Saver is OFF and your app is not on the unrestricted list, it's pretty much like setting push notifications disabled. There is a use case in my app where it's waiting

How to keep footer at bottom of page? [closed]

时光毁灭记忆、已成空白 提交于 2021-02-20 10:25:51
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Improve this question CSS * { margin: 0px; padding: 0px; } html { margin: 0px; padding: 0px; } body { line-height: 1; margin: 0px; padding:0px; background:url("../images/22.jpg") scroll center top #16202C; /* box-shadow: 0 0 225px rgba(0, 0, 0, 0.45) inset; -webkit-box-shadow: 0 0

Why do javascript functions need to have the keyword “async”? Isn't the “await” keyword enough? [closed]

て烟熏妆下的殇ゞ 提交于 2021-02-20 10:25:16
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 4 years ago . Improve this question For instance, why does the function below need to have "async".. isn't using await specific enough for the compiler to parse the code without ambiguity? # Why do we need async here async function foo() { var user = await getUser(user_id); console.log