lifetime

How to Leverage browser caching at ASP.net IIS 7.5

淺唱寂寞╮ 提交于 2019-12-03 01:13:21
The following cacheable resources have a short freshness lifetime. Specify an expiry of at least one week in the future for the following resources: http://pagespeed.googlelabs.com suggest me this for my website as a high priority. I am using windows server 2008 r2 netframework 4.0 asp.net IIS 7.5 . How do i do this ? This is the direct url for you to see : http://pagespeed.googlelabs.com/#url=www.monstermmorpg.com&mobile=false&rule=LeverageBrowserCaching Nikita Ignatov You might start here with this article , also Mads Kristensen had written an interesting blog post on how to compress, minify

Does const reference prolong the life of a temporary object returned by a temporary object?

非 Y 不嫁゛ 提交于 2019-12-02 22:29:11
问题 I know that const reference prolongs the life of a temporary locally. Now I am asking myself if this propriety can be extended on a chain of temporary objects, that is, if I can safely define: std::string const& foo = aBar.getTemporaryObject1().getTemporaryObject2(); My feeling is that, since the the first method aBar.getTemporaryObject1() returns already a temporary object, the propriety doesn't hold for aBar.getTemporaryObject2() . 回答1: The lifetime extension only applies when a reference

Why does the borrow from `HashMap::get` not end when the function returns?

若如初见. 提交于 2019-12-02 20:31:33
问题 Here is emulation of my problem, when a borrow ends too late use std::collections::HashMap; struct Item { capacity: u64 } struct Petrol { name: String, fuel: HashMap<&'static str, Item> } fn buy_gaz(p: &mut Petrol) { match p.fuel.get("gaz") { Some(gaz) => { fire_petrol(p); } None => () } } fn fire_petrol(p: &mut Petrol) { println!("Boom!"); p.fuel.remove("gaz"); p.fuel.remove("benzin"); } fn main() { let mut bt = Petrol { name: "Britii Petrovich".to_string(), fuel: HashMap::new() }; bt.fuel

Why can't I store a value and a reference to that value in the same struct?

守給你的承諾、 提交于 2019-12-02 20:01:15
问题 I have a value and I want to store that value and a reference to something inside that value in my own type: struct Thing { count: u32, } struct Combined<'a>(Thing, &'a u32); fn make_combined<'a>() -> Combined<'a> { let thing = Thing { count: 42 }; Combined(thing, &thing.count) } Sometimes, I have a value and I want to store that value and a reference to that value in the same structure: struct Combined<'a>(Thing, &'a Thing); fn make_combined<'a>() -> Combined<'a> { let thing = Thing::new();

Binding does not live long enough when storing a reference to a vector item in a hash map

夙愿已清 提交于 2019-12-02 15:05:50
问题 I'm new at Rust and still struggling with the borrow checker and getting lifetimes right. Here's a simple struct I've started to build - it stores collections of command-line argument like things (which can be represented by a --string or a -c or both): struct OptionMap<'a, T: 'a> { name: HashMap<String, &'a T>, short_name: HashMap<char, &'a T>, options: Vec<T> } impl<'a, T: 'a> OptionMap<'a, T> { pub fn new() -> OptionMap<'a, T> { OptionMap { name: HashMap::new(), short_name: HashMap::new(),

Why do changes to a const variable not persist between usages?

徘徊边缘 提交于 2019-12-02 10:59:19
问题 I am trying to create a struct to manipulate file storage, but after I change the value it can not be used. I'm sure it's about lifetimes, but I do not understand how I can fix this. use std::error::Error; use std::fs::{File, OpenOptions}; use std::io::{BufRead, BufReader}; use std::option::Option; use std::path::Path; pub struct Storage<'a> { path_str: &'a str, file: Option<File>, } const LOCKED_STORAGE: Storage<'static> = Storage { path_str: &"/tmp/bmoneytmp.bms", file: None, }; pub fn get

error: cannot infer an appropriate lifetime for autoref due to conflicting requirements [E0495]

拟墨画扇 提交于 2019-12-02 10:55:59
问题 First of all: I am fully aware of this post: Cannot infer appropriate lifetime for autoref in Iterator impl and that the problem is probably similar to mine. However, I can't get it working with the knowledge of this thread. The code: use std::str::Chars; use super::token::*; use super::token_stream::TokenStream; pub struct Lexer<'a> { input: Chars<'a>, buffer: String, cur_char: char } impl<'a> Lexer<'a> { pub fn new(iterator: Chars<'a>) -> Lexer { let mut lexer = Lexer { input: iterator,

Does const reference prolong the life of a temporary object returned by a temporary object?

戏子无情 提交于 2019-12-02 09:02:20
I know that const reference prolongs the life of a temporary locally. Now I am asking myself if this propriety can be extended on a chain of temporary objects, that is, if I can safely define: std::string const& foo = aBar.getTemporaryObject1().getTemporaryObject2(); My feeling is that, since the the first method aBar.getTemporaryObject1() returns already a temporary object, the propriety doesn't hold for aBar.getTemporaryObject2() . The lifetime extension only applies when a reference is directly bound to that temporary. For example, initializing another reference from that reference does not

Why can't I store a value and a reference to that value in the same struct?

柔情痞子 提交于 2019-12-02 09:02:12
I have a value and I want to store that value and a reference to something inside that value in my own type: struct Thing { count: u32, } struct Combined<'a>(Thing, &'a u32); fn make_combined<'a>() -> Combined<'a> { let thing = Thing { count: 42 }; Combined(thing, &thing.count) } Sometimes, I have a value and I want to store that value and a reference to that value in the same structure: struct Combined<'a>(Thing, &'a Thing); fn make_combined<'a>() -> Combined<'a> { let thing = Thing::new(); Combined(thing, &thing) } Sometimes, I'm not even taking a reference of the value and I get the same

How to fix: expected concrete lifetime, but found bound lifetime parameter

可紊 提交于 2019-12-02 08:28:19
I'm currently pulling my hear out over this one. I tried to shrink it down to a minimal reproducible example. struct Request; struct ResponseWriter<'a> { dummy: &'a () } #[deriving(Clone)] pub struct RouteStore{ pub routes: Vec<Route>, } #[deriving(Clone)] struct Route { path: String, handler: fn(request: &Request, response: &mut ResponseWriter) } impl RouteStore { pub fn new () -> RouteStore { RouteStore { routes: Vec::new() } } fn add_route (&mut self, path: String, handler: fn(request: &Request, response: &mut ResponseWriter)) -> () { let route = Route { path: path, handler: handler }; self