lifetime

Laravel cookie session lifetime

你说的曾经没有我的故事 提交于 2020-01-14 22:56:48
问题 I used my Laravel as a OAuth2 client, and I need to keep token i cookies. So, I set driver to cookie and keep default value for lifetime 120 When any user check remember me on login, I tried to change lifetime with code: $lifetime = time() + 60 * 60 * 24 * 365;// one year Config::set('session.lifetime', $lifetime); But without success. In any another controller I checked value of lifetime and every time I get default value. \Log::info(\Config::get('session.lifetime')); Edit #1: It is enough?

Laravel cookie session lifetime

允我心安 提交于 2020-01-14 22:52:40
问题 I used my Laravel as a OAuth2 client, and I need to keep token i cookies. So, I set driver to cookie and keep default value for lifetime 120 When any user check remember me on login, I tried to change lifetime with code: $lifetime = time() + 60 * 60 * 24 * 365;// one year Config::set('session.lifetime', $lifetime); But without success. In any another controller I checked value of lifetime and every time I get default value. \Log::info(\Config::get('session.lifetime')); Edit #1: It is enough?

Casting away lifetime constraints?

烂漫一生 提交于 2020-01-13 10:16:12
问题 I'm trying to write a Rust function that casts an input from one lifetime constraint to a same-typed output with a global lifetime constraint (conceptually something like unsafe fn foo<'a, T1, T2>(x: T1) -> T2 where T1: 'a, T2 = T1 + 'static ), but I can't quite figure out how to write it without adding indirection layers like Box . Any ideas? More generally, I'm trying to implement an unsafe thread::scoped in terms of mem::transmute and thread::spawn . spawn requires 'static bounds on its T

Return lazy iterator that depends on data allocated within the function

风格不统一 提交于 2020-01-13 09:24:06
问题 I am new to Rust and reading The Rust Programming Language , and in the Error Handling section there is a "case study" describing a program to read data from a CSV file using the csv and rustc-serialize libraries (using getopts for argument parsing). The author writes a function search that steps through the rows of the csv file using a csv::Reader object and collect those entries whose 'city' field match a specified value into a vector and returns it. I've taken a slightly different approach

Lifetimes in Rust

試著忘記壹切 提交于 2020-01-10 06:52:07
问题 Occasionally I've found myself wanting to write functions that can be called in either of two ways: // With a string literal: let lines = read_file_lines("data.txt"); // With a string pointer: let file_name = ~"data.txt"; let lines = read_file_lines(file_name); My first guess was to use a borrowed pointer ( &str ) for the parameter type, but when that didn't work (it only allowed me to use @str and ~str ), I tried the following (by copying the Rust libraries), which did work. fn read_file

Why would you ever use the same lifetimes for references in a struct?

核能气质少年 提交于 2020-01-10 03:46:11
问题 This question is similar to When is it useful to define multiple lifetimes in a struct?, but hopefully different enough. The answer to that question is helpful but focuses on advantages of one approach (using distinct lifetimes for references in struct) but not on drawbacks (if any). This question, like that, is looking for guidance on how to choose lifetimes when creating structs. Call this the tied together version because x and y are required to have the same lifetime: struct Foo<'a> { x:

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

℡╲_俬逩灬. 提交于 2020-01-06 05:07:26
问题 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();

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

梦想与她 提交于 2020-01-06 05:07:05
问题 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();

Syntax of Rust lifetime specifier

风格不统一 提交于 2020-01-05 07:38:10
问题 I need help understanding lifetime specifiers. I think I get the concept of lifetimes. I watched Memory, Ownership and Lifetimes. I just think if I could work through this small example it might help me with the syntax of lifetimes. A topic I, to date, find confusing. use std::collections::HashMap; fn main() { pub struct User<'a> { pub name: & 'a str } impl <'a>User<'a> { pub fn new(uname: & 'a str, pwd: & 'a str) -> User { User{name: uname} } } pub struct ChatRoom<'a> { pub name: & 'a str,

Textfile-parsing function fails to compile owing to lifetime/borrow error

安稳与你 提交于 2020-01-05 02:54:07
问题 NB. This post was originally part of a larger post that contained two questions (that I'd believed were one error manifesting itself differently), but to comply with site guidelines I've split it into two separate posts, of which this is the second. The first post is here. I'm trying to parse a simple config text file, which contains one three-word entry per line, laid out as follows: ITEM name value ITEM name value //etc. I've reproduced the function which does the parsing (and the