file_name large_stringlengths 4 69 | prefix large_stringlengths 0 26.7k | suffix large_stringlengths 0 24.8k | middle large_stringlengths 0 2.12k | fim_type large_stringclasses 4
values |
|---|---|---|---|---|
set_cover_test.rs | mod bit_vector;
mod set_cover;
use set_cover::minimum_set_cover;
#[test]
fn test_disjoint() {
test(
vec![
vec![0],
vec![1],
vec![2],
],
vec![0, 1, 2],
);
}
#[test]
fn test_one() {
test(
vec![
vec![0, 1, 2],
vec![0... | ],
vec![0, 2],
);
}
fn test(subsets: Vec<Vec<u8>>, expected_cover: Vec<usize>) {
let mut actual_cover = minimum_set_cover(&subsets);
actual_cover.sort();
assert_eq!(expected_cover, actual_cover);
} | test(
vec![
vec![0, 1],
vec![1, 2],
vec![2, 3], | random_line_split |
set_cover_test.rs | mod bit_vector;
mod set_cover;
use set_cover::minimum_set_cover;
#[test]
fn test_disjoint() {
test(
vec![
vec![0],
vec![1],
vec![2],
],
vec![0, 1, 2],
);
}
#[test]
fn | () {
test(
vec![
vec![0, 1, 2],
vec![0],
vec![1],
vec![2],
],
vec![0],
);
}
#[test]
fn test_two() {
test(
vec![
vec![0, 1],
vec![1, 2],
vec![2, 3],
],
vec![0, 2],
);
}
fn... | test_one | identifier_name |
cache_restore.rs | use anyhow::Result;
mod common;
use common::cache::*;
use common::common_args::*;
use common::fixture::*;
use common::input_arg::*;
use common::output_option::*;
use common::process::*;
use common::program::*;
use common::target::*;
use common::test_dir::*;
//------------------------------------------
const USAGE: ... | () -> &'a str {
"" // we don't intent to verify error messages of XML parsing
}
}
impl<'a> OutputProgram<'a> for CacheRestore {
fn missing_output_arg() -> &'a str {
msg::MISSING_OUTPUT_ARG
}
}
impl<'a> MetadataWriter<'a> for CacheRestore {
fn file_not_found() -> &'a str {
msg::... | corrupted_input | identifier_name |
cache_restore.rs | use anyhow::Result;
mod common;
use common::cache::*;
use common::common_args::*;
use common::fixture::*;
use common::input_arg::*;
use common::output_option::*;
use common::process::*;
use common::program::*;
use common::target::*;
use common::test_dir::*;
//------------------------------------------
const USAGE: ... | msg::bad_option_hint(option)
}
}
impl<'a> InputProgram<'a> for CacheRestore {
fn mk_valid_input(td: &mut TestDir) -> Result<std::path::PathBuf> {
mk_valid_xml(td)
}
fn file_not_found() -> &'a str {
msg::FILE_NOT_FOUND
}
fn missing_input_arg() -> &'a str {
msg::... | fn arg_type() -> ArgType {
ArgType::IoOptions
}
fn bad_option_hint(option: &str) -> String { | random_line_split |
cache_restore.rs | use anyhow::Result;
mod common;
use common::cache::*;
use common::common_args::*;
use common::fixture::*;
use common::input_arg::*;
use common::output_option::*;
use common::process::*;
use common::program::*;
use common::target::*;
use common::test_dir::*;
//------------------------------------------
const USAGE: ... |
fn cmd<I>(args: I) -> Command
where
I: IntoIterator,
I::Item: Into<std::ffi::OsString>,
{
cache_restore_cmd(args)
}
fn usage() -> &'a str {
USAGE
}
fn arg_type() -> ArgType {
ArgType::IoOptions
}
fn bad_option_hint(option: &str) -> String ... | {
"thin_restore"
} | identifier_body |
no_0647_palindromic_substrings.rs | struct Solution;
impl Solution {
pub fn count_substrings(s: String) -> i32 | #[cfg(test)]
mod tests {
use super::*;
#[test]
fn
test_count_substrings1() {
assert_eq!(Solution::count_substrings("abc".to_string()), 3);
}
#[test]
fn test_count_substrings2() {
assert_eq!(Solution::count_substrings("aaa".to_string()), 6);
}
}
| {
let s = s.as_bytes();
let n = s.len() as i32;
let mut ans = 0;
for i in 0..(2 * n - 1) {
// i 是中心点,包括了空隙,所以还要求出对应的索引。
// [0, 0], [0, 1], [1, 1], [1, 2] ...
let mut l = i / 2;
let mut r = l + i % 2;
// 从中心点向两边扩散。
wh... | identifier_body |
no_0647_palindromic_substrings.rs | struct Solution;
impl Solution {
pub fn count_substrings(s: String) -> i32 {
let s = s.as_bytes();
let n = s.len() as i32;
let mut ans = 0;
for i in 0..(2 * n - 1) {
// i 是中心点,包括了空隙,所以还要求出对应的索引。
// [0, 0], [0, 1], [1, 1], [1, 2]...
let mut l = i / ... | #[test]
fn test_count_substrings1() {
assert_eq!(Solution::count_substrings("abc".to_string()), 3);
}
#[test]
fn test_count_substrings2() {
assert_eq!(Solution::count_substrings("aaa".to_string()), 6);
}
} |
#[cfg(test)]
mod tests {
use super::*;
| random_line_split |
no_0647_palindromic_substrings.rs | struct Solution;
impl Solution {
pub fn | (s: String) -> i32 {
let s = s.as_bytes();
let n = s.len() as i32;
let mut ans = 0;
for i in 0..(2 * n - 1) {
// i 是中心点,包括了空隙,所以还要求出对应的索引。
// [0, 0], [0, 1], [1, 1], [1, 2]...
let mut l = i / 2;
let mut r = l + i % 2;
// 从中心点向两边... | count_substrings | identifier_name |
lib.rs | // Copyright © 2015, Peter Atashian
// Licensed under the MIT License <LICENSE.md>
//! FFI bindings to winhttp.
#![cfg(windows)]
extern crate winapi;
use winapi::*;
extern "system" {
// pub fn WinHttpAddRequestHeaders();
// pub fn WinHttpAutoProxySvcMain();
// pub fn WinHttpCheckPlatform();
// pub fn Wi... | // pub fn WinHttpWebSocketSend();
// pub fn WinHttpWebSocketShutdown();
// pub fn WinHttpWriteData();
} | random_line_split | |
lib.rs | extern crate semver;
use std::io::prelude::*;
use std::collections::HashMap;
use std::error::Error;
use std::net::SocketAddr;
pub use self::typemap::TypeMap;
mod typemap;
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Scheme {
Http,
Https
}
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Host<'a> {
... |
/// The byte-size of the body, if any
fn content_length(&self) -> Option<u64>;
/// The request's headers, as conduit::Headers.
fn headers<'a>(&'a self) -> &'a Headers;
/// A Reader for the body of the request
fn body<'a>(&'a mut self) -> &'a mut Read;
/// A readable map of extensions
... |
/// The remote IP address of the client or the last proxy that
/// sent the request.
fn remote_addr(&self) -> SocketAddr; | random_line_split |
lib.rs | extern crate semver;
use std::io::prelude::*;
use std::collections::HashMap;
use std::error::Error;
use std::net::SocketAddr;
pub use self::typemap::TypeMap;
mod typemap;
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Scheme {
Http,
Https
}
#[derive(PartialEq, Debug, Clone, Copy)]
pub enum Host<'a> {
... | {
/// The status code as a tuple of the return code and status string
pub status: (u32, &'static str),
/// A Map of the headers
pub headers: HashMap<String, Vec<String>>,
/// A Writer for body of the response
pub body: Box<Read + Send>
}
/// A Handler takes a request and returns a response o... | Response | identifier_name |
dircolors.rs | #![crate_name = "uu_dircolors"]
// This file is part of the uutils coreutils package.
//
// (c) Jian Zeng <anonymousknight96@gmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
//
extern crate glob;
#[macro_use]
extern crate uuc... | fnmatch(&self, pat: &str) -> bool {
pat.parse::<glob::Pattern>().unwrap().matches(self)
}
}
#[derive(PartialEq)]
enum ParseState {
Global,
Matched,
Continue,
Pass,
}
use std::collections::HashMap;
fn parse<T>(lines: T, fmt: OutputFmt, fp: &str) -> Result<String, String>
where T: IntoIt... | if let Some(b) = self.find(char::is_whitespace) {
let key = &self[..b];
if let Some(e) = self[b..].find(|c: char| !c.is_whitespace()) {
(key, &self[b + e..])
} else {
(key, "")
}
} else {
("", "")
}
}
... | identifier_body |
dircolors.rs | #![crate_name = "uu_dircolors"]
// This file is part of the uutils coreutils package.
//
// (c) Jian Zeng <anonymousknight96@gmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
//
extern crate glob;
#[macro_use]
extern crate uuc... | println!("{}", INTERNAL_DB);
return 0;
}
let mut out_format = OutputFmt::Unknown;
if matches.opt_present("csh") || matches.opt_present("c-shell") {
out_format = OutputFmt::CShell;
} else if matches.opt_present("sh") || matches.opt_present("bourne-shell") {
out_format = Outp... | {
disp_err!("extra operand ‘{}’\nfile operands cannot be combined with \
--print-database (-p)",
matches.free[0]);
return 1;
}
| conditional_block |
dircolors.rs | #![crate_name = "uu_dircolors"]
// This file is part of the uutils coreutils package.
//
// (c) Jian Zeng <anonymousknight96@gmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
//
extern crate glob;
#[macro_use]
extern crate uuc... | }
match File::open(matches.free[0].as_str()) {
Ok(f) => {
let fin = BufReader::new(f);
result = parse(fin.lines().filter_map(|l| l.ok()),
out_format,
matches.free[0].as_str())
}
... | } else {
if matches.free.len() > 1 {
disp_err!("extra operand ‘{}’", matches.free[1]);
return 1; | random_line_split |
dircolors.rs | #![crate_name = "uu_dircolors"]
// This file is part of the uutils coreutils package.
//
// (c) Jian Zeng <anonymousknight96@gmail.com>
//
// For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code.
//
extern crate glob;
#[macro_use]
extern crate uuc... | -> &Self {
let mut line = self;
for (n, c) in self.chars().enumerate() {
if c!= '#' {
continue;
}
// Ignore if '#' is at the beginning of line
if n == 0 {
line = &self[..0];
break;
}
... | self) | identifier_name |
event_loop.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains the `EventLoop` type, which is the constellation's
//! view of a script thread. When an `... | (&mut self) {
let _ = self.script_chan.send(ConstellationControlMsg::ExitScriptThread);
}
}
impl EventLoop {
/// Create a new event loop from the channel to its script thread.
pub fn new(script_chan: IpcSender<ConstellationControlMsg>) -> Rc<EventLoop> {
Rc::new(EventLoop {
scri... | drop | identifier_name |
event_loop.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains the `EventLoop` type, which is the constellation's
//! view of a script thread. When an `... |
/// Send a message to the event loop.
pub fn send(&self, msg: ConstellationControlMsg) -> Result<(), IOError> {
self.script_chan.send(msg)
}
/// The underlying channel to the script thread.
pub fn sender(&self) -> IpcSender<ConstellationControlMsg> {
self.script_chan.clone()
}... | {
Rc::new(EventLoop {
script_chan: script_chan,
dont_send_or_sync: PhantomData,
})
} | identifier_body |
event_loop.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
//! This module contains the `EventLoop` type, which is the constellation's
//! view of a script thread. When an `... | /// https://html.spec.whatwg.org/multipage/#event-loop
pub struct EventLoop {
script_chan: IpcSender<ConstellationControlMsg>,
dont_send_or_sync: PhantomData<Rc<()>>,
}
impl Drop for EventLoop {
fn drop(&mut self) {
let _ = self.script_chan.send(ConstellationControlMsg::ExitScriptThread);
}
}
... | use std::marker::PhantomData;
use std::rc::Rc;
| random_line_split |
joiner.rs | // Exercise 2.3
// I were better to be eaten to death with a rust than to be scoured to nothing with perpetual motion.
use std::os;
use std::io::File;
fn xor(a: &[u8], b: &[u8]) -> ~[u8] {
let mut ret = ~[];
for i in range(0, a.len()) {
ret.push(a[i] ^ b[i]);
}
ret
}
fn main() | }
}
}
| {
let args: ~[~str] = os::args();
if args.len() != 3 {
println!("Usage: {:s} <inputfile1> <inputfile2>", args[0]);
} else {
let fname1 = &args[1];
let fname2 = &args[2];
let path1 = Path::new(fname1.clone());
let path2 = Path::new(fname2.clone());
let share_f... | identifier_body |
joiner.rs | // Exercise 2.3
// I were better to be eaten to death with a rust than to be scoured to nothing with perpetual motion.
use std::os;
use std::io::File;
fn xor(a: &[u8], b: &[u8]) -> ~[u8] {
let mut ret = ~[];
for i in range(0, a.len()) {
ret.push(a[i] ^ b[i]);
}
ret
}
fn main() {
let args: ... | ,
(_, _) => fail!("Error opening input files!")
}
}
}
| {
let share1bytes: ~[u8] = share1.read_to_end();
let share2bytes: ~[u8] = share2.read_to_end();
print!("{:s}", std::str::from_utf8_owned(
xor(share1bytes, share2bytes)));
} | conditional_block |
joiner.rs | // Exercise 2.3
// I were better to be eaten to death with a rust than to be scoured to nothing with perpetual motion.
use std::os;
use std::io::File;
fn xor(a: &[u8], b: &[u8]) -> ~[u8] {
let mut ret = ~[];
for i in range(0, a.len()) {
ret.push(a[i] ^ b[i]);
}
ret
}
fn main() {
let args: ... | print!("{:s}", std::str::from_utf8_owned(
xor(share1bytes, share2bytes)));
},
(_, _) => fail!("Error opening input files!")
}
}
} | random_line_split | |
joiner.rs | // Exercise 2.3
// I were better to be eaten to death with a rust than to be scoured to nothing with perpetual motion.
use std::os;
use std::io::File;
fn xor(a: &[u8], b: &[u8]) -> ~[u8] {
let mut ret = ~[];
for i in range(0, a.len()) {
ret.push(a[i] ^ b[i]);
}
ret
}
fn | () {
let args: ~[~str] = os::args();
if args.len()!= 3 {
println!("Usage: {:s} <inputfile1> <inputfile2>", args[0]);
} else {
let fname1 = &args[1];
let fname2 = &args[2];
let path1 = Path::new(fname1.clone());
let path2 = Path::new(fname2.clone());
let share... | main | identifier_name |
main.rs | extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
/// GuessGame from std docs of rust
fn main() {
println!("Guess the number!");
let mut chances: u32 = 0;
// Generate and store a randowm number b/w 1<->100
let secret_number = rand::thread_rng().gen_range(1, 101);
// Go int... |
println!("You guessed: {}", guess);
// Match the respective value of guess wrt secret number
match guess.cmp(&secret_number) {
Ordering::Less => println!("Too small! \n"),
Ordering::Greater => println!("Too big! \n"),
Ordering::Equal => {
... | let guess: u32 = match guess.trim().parse() {
Ok(num) => num, // Match num if everything is OK
Err(_) => continue, // Continue even if anything != OK happens
}; | random_line_split |
main.rs | extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
/// GuessGame from std docs of rust
fn | () {
println!("Guess the number!");
let mut chances: u32 = 0;
// Generate and store a randowm number b/w 1<->100
let secret_number = rand::thread_rng().gen_range(1, 101);
// Go into a infinite loop
loop {
println!("Chances used {}", chances);
println!("Please input your guess... | main | identifier_name |
main.rs | extern crate rand;
use std::io;
use std::cmp::Ordering;
use rand::Rng;
/// GuessGame from std docs of rust
fn main() |
// Convert and shadow(displace) guess into a unsigned 32bit integer
let guess: u32 = match guess.trim().parse() {
Ok(num) => num, // Match num if everything is OK
Err(_) => continue, // Continue even if anything!= OK happens
};
println!("You guessed:... | {
println!("Guess the number!");
let mut chances: u32 = 0;
// Generate and store a randowm number b/w 1<->100
let secret_number = rand::thread_rng().gen_range(1, 101);
// Go into a infinite loop
loop {
println!("Chances used {}", chances);
println!("Please input your guess.")... | identifier_body |
arbitrator.rs | // Copyright 2015-2016 ZFilexfer Developers. See the COPYRIGHT file at the
// top-level directory of this distribution and at
// https://intecture.io/COPYRIGHT.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distribut... | () {
ZSys::init();
let (mut client, router) = ZSys::create_pipe().unwrap();
client.set_rcvtimeo(Some(500));
let (comm, thread) = ZSys::create_pipe().unwrap();
let chunks = vec![
TimedChunk::new("abc".as_bytes(), 0),
TimedChunk::new("abc".as_bytes(), 1),... | test_arbitrator_request | identifier_name |
arbitrator.rs | // Copyright 2015-2016 ZFilexfer Developers. See the COPYRIGHT file at the
// top-level directory of this distribution and at
// https://intecture.io/COPYRIGHT.
//
// Licensed under the Mozilla Public License 2.0 <LICENSE or
// https://www.tldrlegal.com/l/mpl-2.0>. This file may not be copied,
// modified, or distribut... |
fn run(mut self) {
loop {
// Terminate on ZSock signal or system signal (SIGTERM)
if self.comm.wait().is_ok() || ZSys::is_interrupted() {
break;
}
for chunk in self.chunks.read().unwrap().iter() {
if chunk.is_expired() {
... | })
} | random_line_split |
generic-functions-nested.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
// lldb-command:print x
// lldb-check:[...]$2 = -1
// lldb-command:print y
// lldb-check:[...]$3 = 2.5
// lldb-command:continue
// lldb-command:print x
// lldb-check:[...]$4 = -2.5
// lldb-command:print y
// lldb-check:[...]$5 = 1
// lldb-command:continue
// lldb-command:print x
// lldb-check:[...]$6 = -2.5
// lldb-... | // lldb-command:continue | random_line_split |
generic-functions-nested.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn zzz() { () }
| {
outer(-1);
outer(-2.5f64);
} | identifier_body |
generic-functions-nested.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | () { () }
| zzz | identifier_name |
union.rs | use racer_testutils::*;
#[test]
fn completes_union() {
let src = r#"
#[repr(C)]
union MyUnion {
f1: u32,
f2: f32,
}
let u: MyU~
"#;
let got = get_only_completion(src, None);
assert_eq!(got.matchstr, "MyUnion");
}
#[test]
fn completes_maybe_uninit() |
#[test]
fn completes_union_member() {
let src = r#"
#[repr(C)]
union MyUnion {
uint_member: u32,
float_member: f32,
}
impl MyUnion {
fn new() -> Self { Self { uint_member: 10 } }
}
let uni = unsafe { MyUnion::new().uint~ };
"#;
let got = get_only_completion(src,... | {
let src = r#"
let u: std::mem::Mayb~
"#;
let got = get_only_completion(src, None);
assert_eq!(got.matchstr, "MaybeUninit");
} | identifier_body |
union.rs | use racer_testutils::*;
#[test]
fn | () {
let src = r#"
#[repr(C)]
union MyUnion {
f1: u32,
f2: f32,
}
let u: MyU~
"#;
let got = get_only_completion(src, None);
assert_eq!(got.matchstr, "MyUnion");
}
#[test]
fn completes_maybe_uninit() {
let src = r#"
let u: std::mem::Mayb~
"#;
let got = get_only_co... | completes_union | identifier_name |
union.rs | use racer_testutils::*;
#[test]
fn completes_union() {
let src = r#"
#[repr(C)]
union MyUnion {
f1: u32,
f2: f32,
}
let u: MyU~
"#;
let got = get_only_completion(src, None);
assert_eq!(got.matchstr, "MyUnion");
}
#[test]
fn completes_maybe_uninit() {
let src = r#"
l... | }
#[test]
fn completes_union_member() {
let src = r#"
#[repr(C)]
union MyUnion {
uint_member: u32,
float_member: f32,
}
impl MyUnion {
fn new() -> Self { Self { uint_member: 10 } }
}
let uni = unsafe { MyUnion::new().uint~ };
"#;
let got = get_only_completion(src... | assert_eq!(got.matchstr, "MaybeUninit"); | random_line_split |
method_definitions.rs | struct Point<T> {
x: T,
y: T,
}
/* Declare `impl<T>` to specify we are implementing
* methods on type `Point<T>`
*/
impl<T> Point<T> { | &self.x
}
// fn distance_from_origin<f32>(&self) -> f32 {
// (self.x.powi(2) + self.y.powi(2)).sqrt()
// }
}
struct PointMixed<T, U> {
x: T,
y: U,
}
impl<T, U> PointMixed<T, U> {
// `V` and `W` types are only relevant to the method definition
fn mixup<V, W>(self, other: Po... | /* Getter method `x` returns "reference" to the
* data in field type `T`
*/
fn x(&self) -> &T { | random_line_split |
method_definitions.rs | struct Point<T> {
x: T,
y: T,
}
/* Declare `impl<T>` to specify we are implementing
* methods on type `Point<T>`
*/
impl<T> Point<T> {
/* Getter method `x` returns "reference" to the
* data in field type `T`
*/
fn | (&self) -> &T {
&self.x
}
// fn distance_from_origin<f32>(&self) -> f32 {
// (self.x.powi(2) + self.y.powi(2)).sqrt()
// }
}
struct PointMixed<T, U> {
x: T,
y: U,
}
impl<T, U> PointMixed<T, U> {
// `V` and `W` types are only relevant to the method definition
fn mixup<V, W>... | x | identifier_name |
events.rs | #[derive(Clone, Debug, Copy)]
pub enum Event {
/// The size of the window has changed.
Resized(u32, u32),
/// The position of the window has changed.
Moved(i32, i32),
/// The window has been closed.
Closed,
/// The window received a unicode character.
ReceivedCharacter(char),
///... | {
Pressed,
Released,
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum MouseButton {
Left,
Right,
Middle,
Other(u8),
}
#[derive(Debug, Hash, PartialEq, Eq, Clone, Copy)]
pub enum VirtualKeyCode {
/// The '1' key over the letters.
Key1,
/// The '2' key over the letters.... | ElementState | identifier_name |
events.rs | #[derive(Clone, Debug, Copy)]
pub enum Event {
/// The size of the window has changed.
Resized(u32, u32),
/// The position of the window has changed.
Moved(i32, i32),
/// The window has been closed.
Closed,
/// The window received a unicode character.
ReceivedCharacter(char),
///... | G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
Q,
R,
S,
T,
U,
V,
W,
X,
Y,
Z,
/// The Escape key, next to F1.
Escape,
F1,
F2,
F3,
F4,
F5,
F6,
F7,
F8,
F9,
F10,
F11,
F12,
F13,
F14,
F15,
... | C,
D,
E,
F, | random_line_split |
mod.rs | use std::default::Default;
use std::fs::File; | use std::process::exit;
use std::io::{Write};
use std::os::unix::io::FromRawFd;
use argparse::{ArgumentParser, Store};
use config::read_config;
use config::Settings;
mod version;
pub use self::version::{short_version, Error};
pub fn run() -> i32 {
let mut container: String = "".to_string();
let mut setti... | use std::path::Path; | random_line_split |
mod.rs | use std::default::Default;
use std::fs::File;
use std::path::Path;
use std::process::exit;
use std::io::{Write};
use std::os::unix::io::FromRawFd;
use argparse::{ArgumentParser, Store};
use config::read_config;
use config::Settings;
mod version;
pub use self::version::{short_version, Error};
pub fn run() -> i32 ... |
Err(e) => {
error!("Error writing hash: {}", e);
return 1;
}
}
return 0;
}
pub fn main() {
let val = run();
exit(val);
}
| {} | conditional_block |
mod.rs | use std::default::Default;
use std::fs::File;
use std::path::Path;
use std::process::exit;
use std::io::{Write};
use std::os::unix::io::FromRawFd;
use argparse::{ArgumentParser, Store};
use config::read_config;
use config::Settings;
mod version;
pub use self::version::{short_version, Error};
pub fn run() -> i32 | }
// TODO(tailhook) read also config from /work/.vagga/vagga.yaml
let cfg = read_config(&Path::new("/work/vagga.yaml")).ok()
.expect("Error parsing configuration file"); // TODO
let cont = cfg.containers.get(&container)
.expect("Container not found"); // TODO
let hash = match versi... | {
let mut container: String = "".to_string();
let mut settings: Settings = Default::default();
{
let mut ap = ArgumentParser::new();
ap.set_description("
A tool which versions containers
");
ap.refer(&mut container)
.add_argument("container", Store,
... | identifier_body |
mod.rs | use std::default::Default;
use std::fs::File;
use std::path::Path;
use std::process::exit;
use std::io::{Write};
use std::os::unix::io::FromRawFd;
use argparse::{ArgumentParser, Store};
use config::read_config;
use config::Settings;
mod version;
pub use self::version::{short_version, Error};
pub fn | () -> i32 {
let mut container: String = "".to_string();
let mut settings: Settings = Default::default();
{
let mut ap = ArgumentParser::new();
ap.set_description("
A tool which versions containers
");
ap.refer(&mut container)
.add_argument("container"... | run | identifier_name |
actorref.rs | ///A reference to a spawned actorpub trait ActorRef { }
pub trait ActorRef{ }
///Spawned actor reference with port and channel
pub struct ActorRefWithStream<P2, C1> {
port: P2,
chan: C1,
}
impl <T1: Send, T2: Send, C1: GenericChan<T1>, P2: GenericPort<T2>> ActorRef
for ActorRefWithStream<P2, C1> {}
/... | <C1>{
chan: C1,
}
impl<T1: Send, C1: GenericChan<T1>> ActorRef for ActorRefWithChan<C1>{}
///Spawned actor reference with port
pub struct ActorRefWithPort<P2>{
port: P2,
}
impl<T2: Send, P2: GenericPort<T2>> ActorRef for ActorRefWithPort<P2>{}
///Spawned actor reference with no port and channel
pub struct ... | ActorRefWithChan | identifier_name |
actorref.rs | ///A reference to a spawned actorpub trait ActorRef { }
pub trait ActorRef{ }
///Spawned actor reference with port and channel
pub struct ActorRefWithStream<P2, C1> {
port: P2,
chan: C1, | }
impl <T1: Send, T2: Send, C1: GenericChan<T1>, P2: GenericPort<T2>> ActorRef
for ActorRefWithStream<P2, C1> {}
///Spawned actor reference with channel
pub struct ActorRefWithChan<C1>{
chan: C1,
}
impl<T1: Send, C1: GenericChan<T1>> ActorRef for ActorRefWithChan<C1>{}
///Spawned actor reference with port... | random_line_split | |
phantom-data-is-structurally-matchable.rs | // run-pass
// This file checks that `PhantomData` is considered structurally matchable.
use std::marker::PhantomData;
fn main() {
let mut count = 0;
// A type which is not structurally matchable:
struct NotSM;
// And one that is:
#[derive(PartialEq, Eq)]
struct SM;
// Check that SM is... | {
alpha: PhantomData<NotSM>,
beta: PhantomData<SM>,
}
const CFOO: Foo = Foo {
alpha: PhantomData,
beta: PhantomData,
};
match Foo::default() {
CFOO => count += 1,
};
// Final count must be 4 now if all
assert_eq!(count, 4);
}
| Foo | identifier_name |
phantom-data-is-structurally-matchable.rs | // run-pass
// This file checks that `PhantomData` is considered structurally matchable.
use std::marker::PhantomData;
fn main() | };
// Check that PhantomData<T> is #[structural_match] when T is.
const CPD2: PhantomData<SM> = PhantomData;
match PhantomData {
CPD2 => count += 1,
};
// Check that a type which has a PhantomData is `#[structural_match]`.
#[derive(PartialEq, Eq, Default)]
struct Foo {
... | {
let mut count = 0;
// A type which is not structurally matchable:
struct NotSM;
// And one that is:
#[derive(PartialEq, Eq)]
struct SM;
// Check that SM is #[structural_match]:
const CSM: SM = SM;
match SM {
CSM => count += 1,
};
// Check that PhantomData<T> is ... | identifier_body |
phantom-data-is-structurally-matchable.rs | // run-pass
// This file checks that `PhantomData` is considered structurally matchable.
use std::marker::PhantomData;
fn main() {
let mut count = 0;
// A type which is not structurally matchable:
struct NotSM;
// And one that is:
#[derive(PartialEq, Eq)]
struct SM;
// Check that SM is... | alpha: PhantomData,
beta: PhantomData,
};
match Foo::default() {
CFOO => count += 1,
};
// Final count must be 4 now if all
assert_eq!(count, 4);
} | alpha: PhantomData<NotSM>,
beta: PhantomData<SM>,
}
const CFOO: Foo = Foo { | random_line_split |
doc.rs | use std::{fs, path::Path};
use {itertools::Itertools, rayon::prelude::*};
use gluon_doc as doc;
use gluon::{check::metadata::metadata, RootedThread, ThreadExt};
fn new_vm() -> RootedThread {
::gluon::VmBuilder::new()
.import_paths(Some(vec!["..".into()]))
.build()
}
fn doc_check(module: &str, exp... | () {
let module = r#"
/// This is the test function
let test x = x
{ test }
"#;
doc_check(
module,
doc::Record {
types: Vec::new(),
values: vec![doc::Field {
name: "test".to_string(),
args: vec![doc::Argument {
implicit:... | basic | identifier_name |
doc.rs | use std::{fs, path::Path};
use {itertools::Itertools, rayon::prelude::*};
use gluon_doc as doc;
use gluon::{check::metadata::metadata, RootedThread, ThreadExt};
fn new_vm() -> RootedThread {
::gluon::VmBuilder::new()
.import_paths(Some(vec!["..".into()]))
.build()
}
fn doc_check(module: &str, exp... |
doc::generate_for_path(&new_vm(), "../std", out).unwrap_or_else(|err| panic!("{}", err));
let out = fs::canonicalize(out).unwrap();
let errors = cargo_deadlinks::unavailable_urls(
&out,
&cargo_deadlinks::CheckContext { check_http: true },
)
.collect::<Vec<_>>();
assert!(errors.... | {
fs::remove_dir_all(out).unwrap_or_else(|err| panic!("{}", err));
} | conditional_block |
doc.rs | use std::{fs, path::Path};
use {itertools::Itertools, rayon::prelude::*};
use gluon_doc as doc;
use gluon::{check::metadata::metadata, RootedThread, ThreadExt};
fn new_vm() -> RootedThread {
::gluon::VmBuilder::new()
.import_paths(Some(vec!["..".into()]))
.build()
}
fn doc_check(module: &str, exp... | }],
},
);
}
#[test]
fn doc_hidden() {
let module = r#"
#[doc(hidden)]
type Test = Int
#[doc(hidden)]
let test x = x
{ Test, test }
"#;
doc_check(
module,
doc::Record {
types: Vec::new(),
values: vec![],
},
);
}
#[test]
fn check_links... | {
let module = r#"
/// This is the test function
let test x = x
{ test }
"#;
doc_check(
module,
doc::Record {
types: Vec::new(),
values: vec![doc::Field {
name: "test".to_string(),
args: vec![doc::Argument {
implicit: fa... | identifier_body |
doc.rs | use std::{fs, path::Path};
use {itertools::Itertools, rayon::prelude::*};
use gluon_doc as doc;
use gluon::{check::metadata::metadata, RootedThread, ThreadExt};
fn new_vm() -> RootedThread {
::gluon::VmBuilder::new()
.import_paths(Some(vec!["..".into()]))
.build()
}
fn doc_check(module: &str, exp... |
#[test]
fn check_links() {
let _ = env_logger::try_init();
let out = Path::new("../target/doc_test");
if out.exists() {
fs::remove_dir_all(out).unwrap_or_else(|err| panic!("{}", err));
}
doc::generate_for_path(&new_vm(), "../std", out).unwrap_or_else(|err| panic!("{}", err));
let out ... | random_line_split | |
requests.rs | use std::slice::Iter;
use super::{ Request };
pub struct Requests<'a> {
request: Option<&'a Request>,
requests: Iter<'a, Request>,
}
impl<'a> Requests<'a> {
pub fn new(request: &'a Request, requests: &'a Vec<Request>) -> Requests<'a> {
Requests {
request: Some(request),
requests: requests.iter()... | ,
(request, _) => request,
}
}
fn size_hint(&self) -> (usize, Option<usize>) {
match (self.request, self.requests.size_hint()) {
(None, size_hint) => size_hint,
(Some(_), (min, max)) => (min + 1, max.map(|max| max + 1)),
}
}
}
| {
self.request = None;
request
} | conditional_block |
requests.rs | use std::slice::Iter;
use super::{ Request }; | }
impl<'a> Requests<'a> {
pub fn new(request: &'a Request, requests: &'a Vec<Request>) -> Requests<'a> {
Requests {
request: Some(request),
requests: requests.iter(),
}
}
}
impl<'a> Iterator for Requests<'a> {
type Item = &'a Request;
fn next(&mut self) -> Option<&'a Request> {
match ... |
pub struct Requests<'a> {
request: Option<&'a Request>,
requests: Iter<'a, Request>, | random_line_split |
requests.rs | use std::slice::Iter;
use super::{ Request };
pub struct Requests<'a> {
request: Option<&'a Request>,
requests: Iter<'a, Request>,
}
impl<'a> Requests<'a> {
pub fn | (request: &'a Request, requests: &'a Vec<Request>) -> Requests<'a> {
Requests {
request: Some(request),
requests: requests.iter(),
}
}
}
impl<'a> Iterator for Requests<'a> {
type Item = &'a Request;
fn next(&mut self) -> Option<&'a Request> {
match (self.requests.next(), self.request) {
... | new | identifier_name |
newlambdas.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | assert_eq!(f(10, |a| a), 10);
g(||{});
} | g(||()); | random_line_split |
newlambdas.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
assert_eq!(f(10, |a| a), 10);
g(||());
assert_eq!(f(10, |a| a), 10);
g(||{});
}
| main | identifier_name |
newlambdas.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn g<G>(_g: G) where G: FnOnce() { }
pub fn main() {
assert_eq!(f(10, |a| a), 10);
g(||());
assert_eq!(f(10, |a| a), 10);
g(||{});
}
| { f(i) } | identifier_body |
mod.rs |
pass_name,
tcx,
mir_body,
source_file,
fn_sig_span,
body_span,
basic_coverage_blocks,
coverage_counters: CoverageCounters::new(function_source_hash),
}
}
fn inject_counters(&'a mut self) {
let tcx =... | hash_mir_source | identifier_name | |
mod.rs | mir_source.def_id()
);
return;
}
let hir_id = tcx.hir().local_def_id_to_hir_id(mir_source.def_id().expect_local());
let is_fn_like = FnLikeNode::from_node(tcx.hir().get(hir_id)).is_some();
// Only instrument functions, methods, and closures (not co... | self.bcb_leader_bb(bcb),
Some(make_code_region(source_map, file_name, &self.source_file, span, body_span)),
);
}
}
/// `inject_coverage_span_counters()` looped through the `CoverageSpan`s and injected the
/// counter from the `CoverageSpan`s `BasicCoverag... | );
inject_statement(
self.mir_body,
counter_kind, | random_line_split |
mod.rs | mir_source.def_id()
);
return;
}
let hir_id = tcx.hir().local_def_id_to_hir_id(mir_source.def_id().expect_local());
let is_fn_like = FnLikeNode::from_node(tcx.hir().get(hir_id)).is_some();
// Only instrument functions, methods, and closures (not cons... | new_bb
} else {
let target_bb = self.bcb_last_bb(target_bcb);
graphviz_data.add_bcb_dependency_counter(target_bcb, &counter_kind);
debug!(
"{:?} ({:?}) gets a new Coverage stat... | {
let inject_to_bb = if let Some(from_bcb) = edge_from_bcb {
// The MIR edge starts `from_bb` (the outgoing / last BasicBlock in
// `from_bcb`) and ends at `to_bb` (the incoming / first BasicBlock in the
// `target_bcb`; also ca... | conditional_block |
codemap.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
filename: FileName,
line: uint,
col: CharPos,
file: Option<@FileMap>,
}
// used to be structural records. Better names, anyone?
pub struct FileMapAndLine {fm: @FileMap, line: uint}
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
#[deriving(IterBytes)]
pub enum MacroFormat {
// e.g. #[... | LocWithOpt | identifier_name |
codemap.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
// used to be structural records. Better names, anyone?
pub struct FileMapAndLine {fm: @FileMap, line: uint}
pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
#[deriving(IterBytes)]
pub enum MacroFormat {
// e.g. #[deriving(...)] <item>
MacroAttribute,
// e.g. `format!()`
MacroBang
}
#[derivi... | filename: FileName,
line: uint,
col: CharPos,
file: Option<@FileMap>,
} | random_line_split |
codemap.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
impl Add<CharPos,CharPos> for CharPos {
fn add(&self, rhs: &CharPos) -> CharPos {
CharPos(self.to_uint() + rhs.to_uint())
}
}
impl Sub<CharPos,CharPos> for CharPos {
fn sub(&self, rhs: &CharPos) -> CharPos {
CharPos(self.to_uint() - rhs.to_uint())
}
}
/**
Spans represent a region o... | { let CharPos(n) = *self; n } | identifier_body |
check_const.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | v.tcx.sess.span_err(e.span,
"paths in constants may only refer to \
constants or functions");
}
None => {
v.tcx.sess.span_bug(e.span, "unbound path in const?!");
}
}
}
ExprC... | Some(&DefStruct(_)) => { }
Some(&def) => {
debug!("(checking const) found bad def: {:?}", def); | random_line_split |
check_const.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&mut self, i: &Item, env: bool) {
check_item(self, i, env);
}
fn visit_pat(&mut self, p: &Pat, env: bool) {
check_pat(self, p, env);
}
fn visit_expr(&mut self, ex: &Expr, env: bool) {
check_expr(self, ex, env);
}
}
pub fn check_crate(krate: &Crate, tcx: &ty::ctxt) {
vis... | visit_item | identifier_name |
check_const.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
Some(&def) => {
debug!("(checking const) found bad def: {:?}", def);
v.tcx.sess.span_err(e.span,
"paths in constants may only refer to \
constants or functions");
}
None => {
v.tcx.sess.s... | { } | conditional_block |
check_const.rs | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
fn visit_expr(&mut self, e: &Expr, _: ()) {
match e.node {
ExprPath(..) => {
match self.def_map.borrow().find(&e.id) {
Some(&DefStatic(def_id, _)) if
ast_util::is_local(def_id) => {
self.visit_item(&*self.a... | {
if self.idstack.iter().any(|x| x == &(it.id)) {
self.sess.span_fatal(self.root_it.span, "recursive constant");
}
self.idstack.push(it.id);
visit::walk_item(self, it, ());
self.idstack.pop();
} | identifier_body |
cell_manhattan_inv.rs | // Copyright 2015 The Noise-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ... | {
cell4_manhattan_inv(seed, &[point[0] / 16.0, point[1] / 16.0, point[0] / 16.0, point[1] / 16.0]) * 2.0 - 1.0
} | identifier_body | |
cell_manhattan_inv.rs | // Copyright 2015 The Noise-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ... | // See the License for the specific language governing permissions and
// limitations under the License.
//! An example of using cell range noise
extern crate noise;
use noise::{cell2_manhattan_inv, cell3_manhattan_inv, cell4_manhattan_inv, Seed, Point2};
mod debug;
fn main() {
debug::render_png("cell2_manhatt... | random_line_split | |
cell_manhattan_inv.rs | // Copyright 2015 The Noise-rs Developers.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ... | () {
debug::render_png("cell2_manhattan_inv.png", &Seed::new(0), 1024, 1024, scaled_cell2_manhattan_inv);
debug::render_png("cell3_manhattan_inv.png", &Seed::new(0), 1024, 1024, scaled_cell3_manhattan_inv);
debug::render_png("cell4_manhattan_inv.png", &Seed::new(0), 1024, 1024, scaled_cell4_manhattan_inv);
... | main | identifier_name |
enum.rs | // Copyright 2015, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
extern crate winreg;
use std::io;
use winreg::enums::*;
use winreg::RegKey;
fn main() -> io::Result<()> {
... |
Ok(())
} | println!("{} = {:?}", name, value);
} | random_line_split |
enum.rs | // Copyright 2015, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
extern crate winreg;
use std::io;
use winreg::enums::*;
use winreg::RegKey;
fn main() -> io::Result<()> | {
println!("File extensions, registered in system:");
for i in RegKey::predef(HKEY_CLASSES_ROOT)
.enum_keys()
.map(|x| x.unwrap())
.filter(|x| x.starts_with('.'))
{
println!("{}", i);
}
let system = RegKey::predef(HKEY_LOCAL_MACHINE).open_subkey("HARDWARE\\DESCRIPTIO... | identifier_body | |
enum.rs | // Copyright 2015, Igor Shaula
// Licensed under the MIT License <LICENSE or
// http://opensource.org/licenses/MIT>. This file
// may not be copied, modified, or distributed
// except according to those terms.
extern crate winreg;
use std::io;
use winreg::enums::*;
use winreg::RegKey;
fn | () -> io::Result<()> {
println!("File extensions, registered in system:");
for i in RegKey::predef(HKEY_CLASSES_ROOT)
.enum_keys()
.map(|x| x.unwrap())
.filter(|x| x.starts_with('.'))
{
println!("{}", i);
}
let system = RegKey::predef(HKEY_LOCAL_MACHINE).open_subkey("HA... | main | identifier_name |
article.rs | use chrono::naive::NaiveDateTime;
use serde::{Deserialize, Serialize};
use validator::Validate;
use crate::schema::articles;
#[derive(Debug, Clone, Queryable, Insertable, Serialize, Deserialize)]
pub struct Article {
pub id: i32,
pub author_id: i32,
pub in_reply_to: Option<String>,
| pub article_format: String,
pub excerpt: Option<String>,
pub body: String,
pub published: bool,
pub inserted_at: NaiveDateTime,
pub updated_at: NaiveDateTime,
pub posse: bool,
pub lang: String,
}
#[derive(Deserialize, Serialize, Debug, Insertable, Clone, Validate, Default)]
#[table_... | pub title: String,
pub slug: String,
pub guid: String, | random_line_split |
article.rs | use chrono::naive::NaiveDateTime;
use serde::{Deserialize, Serialize};
use validator::Validate;
use crate::schema::articles;
#[derive(Debug, Clone, Queryable, Insertable, Serialize, Deserialize)]
pub struct Article {
pub id: i32,
pub author_id: i32,
pub in_reply_to: Option<String>,
pub title: String,... | {
pub author_id: Option<i32>,
pub in_reply_to: Option<String>,
#[validate(length(min = 3, max = 255))]
pub title: String,
#[validate(length(min = 3, max = 255))]
pub slug: String,
pub guid: Option<String>,
pub article_format: Option<String>,
pub excerpt: Option<String>,
#[val... | NewArticle | identifier_name |
chrono.rs | //! This module makes it possible to map `chrono::DateTime` values to postgres `Date`
//! and `Timestamp` fields. It is enabled with the `chrono` feature.
extern crate chrono;
use std::error::Error;
use std::io::Write;
use self::chrono::{Duration, NaiveDateTime, NaiveDate, NaiveTime};
use expression::AsExpression;
us... |
}
| {
let connection = connection();
let midnight = NaiveTime::from_hms(0, 0, 0);
let query = select(sql::<Time>("'00:00:00'::time"));
assert_eq!(Ok(midnight), query.get_result::<NaiveTime>(&connection));
let noon = NaiveTime::from_hms(12, 0, 0);
let query = select(sql::<Tim... | identifier_body |
chrono.rs | //! This module makes it possible to map `chrono::DateTime` values to postgres `Date`
//! and `Timestamp` fields. It is enabled with the `chrono` feature.
extern crate chrono;
use std::error::Error; | use query_source::Queryable;
use super::{PgTime, PgTimestamp};
use types::{self, FromSql, IsNull, Time, Timestamp, ToSql};
expression_impls! {
Time -> NaiveTime,
Timestamp -> NaiveDateTime,
}
queryable_impls! {
Time -> NaiveTime,
Timestamp -> NaiveDateTime,
}
// Postgres timestamps start from January... | use std::io::Write;
use self::chrono::{Duration, NaiveDateTime, NaiveDate, NaiveTime};
use expression::AsExpression;
use expression::bound::Bound; | random_line_split |
chrono.rs | //! This module makes it possible to map `chrono::DateTime` values to postgres `Date`
//! and `Timestamp` fields. It is enabled with the `chrono` feature.
extern crate chrono;
use std::error::Error;
use std::io::Write;
use self::chrono::{Duration, NaiveDateTime, NaiveDate, NaiveTime};
use expression::AsExpression;
us... | () -> Connection {
dotenv().ok();
let connection_url = ::std::env::var("DATABASE_URL").ok()
.expect("DATABASE_URL must be set in order to run tests");
Connection::establish(&connection_url).unwrap()
}
#[test]
fn unix_epoch_encodes_correctly() {
let connection = c... | connection | identifier_name |
main.rs | #[macro_use] extern crate serde_derive;
extern crate serde;
extern crate serde_xml_rs;
extern crate quick_xml;
//extern crate serde_derive;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::str;
use serde_xml_rs::deserialize;
mod server;
mod iso8583_parser;
struct Configuration {
address: String... | {
let config :Configuration;
config = read_configuration();
let listening_address = format!("{}:{}", config.address, config.port);
server::start_listening(listening_address);
} | identifier_body | |
main.rs | #[macro_use] extern crate serde_derive;
extern crate serde;
extern crate serde_xml_rs;
extern crate quick_xml;
//extern crate serde_derive;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::str;
use serde_xml_rs::deserialize;
mod server;
mod iso8583_parser;
struct Configuration {
address: String... | () {
let config :Configuration;
config = read_configuration();
let listening_address = format!("{}:{}", config.address, config.port);
server::start_listening(listening_address);
}
| main | identifier_name |
main.rs | #[macro_use] extern crate serde_derive;
extern crate serde;
extern crate serde_xml_rs;
extern crate quick_xml;
//extern crate serde_derive;
use std::env;
use std::fs::File;
use std::io::prelude::*; |
mod server;
mod iso8583_parser;
struct Configuration {
address: String,
port: String,
}
//read connection configuration from config.xml and set it in 'Configuration' struct
fn read_configuration() -> Configuration
{
use quick_xml::reader::Reader;
use quick_xml::events::Event;
let mut cfg: Config... | use std::str;
use serde_xml_rs::deserialize;
| random_line_split |
issue-13560.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {} | random_line_split | |
issue-13560.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
| main | identifier_name |
issue-13560.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {} | identifier_body | |
liveness-dead.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn main() {} | random_line_split | |
liveness-dead.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn f2() {
let mut x: int = 3; //~ ERROR: value assigned to `x` is never read
x = 4;
x.clone();
}
fn f3() {
let mut x: int = 3;
x.clone();
x = 4; //~ ERROR: value assigned to `x` is never read
}
fn main() {}
| {
*x = 1; // no error
} | identifier_body |
liveness-dead.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let mut x: int = 3; //~ ERROR: value assigned to `x` is never read
x = 4;
x.clone();
}
fn f3() {
let mut x: int = 3;
x.clone();
x = 4; //~ ERROR: value assigned to `x` is never read
}
fn main() {}
| f2 | identifier_name |
renderer.rs | use std::fmt;
use std::error::Error;
use super::format::{Format, DefaultFormat};
use super::builders::Builder;
use super::output::Output;
use super::super::error::ParseError;
use super::super::ast::Block;
#[derive(Debug)]
pub enum RenderError {
ParseError(ParseError),
}
///
/// # Example
///
/// ```
/// use squid... | I: Iterator<Item = Result<Block, ParseError>>,
{
///
/// Creates a new renderer with the default implementation of `Format`.
///
pub fn new(input: I) -> Self {
Renderer {
input,
format: DefaultFormat,
}
}
}
impl fmt::Display for RenderError {
fn fmt(&... | input: I,
}
impl<I> Renderer<DefaultFormat, I>
where | random_line_split |
renderer.rs | use std::fmt;
use std::error::Error;
use super::format::{Format, DefaultFormat};
use super::builders::Builder;
use super::output::Output;
use super::super::error::ParseError;
use super::super::ast::Block;
#[derive(Debug)]
pub enum RenderError {
ParseError(ParseError),
}
///
/// # Example
///
/// ```
/// use squid... | (&self) -> &str {
match *self {
RenderError::ParseError(ref err) => err.description(),
}
}
fn cause(&self) -> Option<&Error> {
match *self {
RenderError::ParseError(ref err) => Some(err),
}
}
}
impl From<ParseError> for RenderError {
fn from(err:... | description | identifier_name |
renderer.rs | use std::fmt;
use std::error::Error;
use super::format::{Format, DefaultFormat};
use super::builders::Builder;
use super::output::Output;
use super::super::error::ParseError;
use super::super::ast::Block;
#[derive(Debug)]
pub enum RenderError {
ParseError(ParseError),
}
///
/// # Example
///
/// ```
/// use squid... |
}
| {
let node = self.input.next()?.and_then(|block| {
let mut builder = Builder::new();
match block {
Block::Heading(level, content) => self.format.heading(&mut builder, level, content),
Block::Paragraph(text) => self.format.paragraph(&mut builder, text),
... | identifier_body |
issue-11085.rs | // Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICEN... |
}
let _f = Bar3::Bar3_1 { bar: 3 };
}
| {} | conditional_block |
issue-11085.rs | // Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICEN... | #[cfg(foo)]
foo: isize,
}
enum Bar1 {
Bar1_1,
#[cfg(fail)]
Bar1_2(NotAType),
}
enum Bar2 {
#[cfg(fail)]
Bar2_1(NotAType),
}
enum Bar3 {
Bar3_1 {
#[cfg(fail)]
foo: isize,
bar: isize,
}
}
pub fn main() {
let _f = Foo { foo: 3 };
let _f = Foo2 { foo: ... | }
struct Foo2 { | random_line_split |
issue-11085.rs | // Copyright 2012-2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICEN... | {
Bar1_1,
#[cfg(fail)]
Bar1_2(NotAType),
}
enum Bar2 {
#[cfg(fail)]
Bar2_1(NotAType),
}
enum Bar3 {
Bar3_1 {
#[cfg(fail)]
foo: isize,
bar: isize,
}
}
pub fn main() {
let _f = Foo { foo: 3 };
let _f = Foo2 { foo: 3 };
match Bar1::Bar1_1 {
Bar1:... | Bar1 | identifier_name |
lambda-infer-unresolved.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | {
let mut e = Refs{refs: vec!(), n: 0};
let _f = || println!("{}", e.n);
let x: &[isize] = &e.refs;
assert_eq!(x.len(), 0);
} | identifier_body | |
lambda-infer-unresolved.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | { refs: Vec<isize>, n: isize }
pub fn main() {
let mut e = Refs{refs: vec!(), n: 0};
let _f = || println!("{}", e.n);
let x: &[isize] = &e.refs;
assert_eq!(x.len(), 0);
}
| Refs | identifier_name |
lambda-infer-unresolved.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | // This should typecheck even though the type of e is not fully
// resolved when we finish typechecking the ||.
struct Refs { refs: Vec<isize>, n: isize }
pub fn main() {
let mut e = Refs{refs: vec!(), n: 0};
let _f = || println!("{}", e.n);
let x: &[isize] = &e.refs;
assert_eq!(x.len(), 0);
} | random_line_split | |
result.rs | use std::io::Error as IoError;
use std::sync::mpsc::{SendError, RecvError};
use std::result;
use mio::NotifyError;
use queue::Message;
use {Handler};
#[derive(Debug)]
pub enum Error<H: Handler> {
QueueOutOfService,
Io(IoError),
NotifyError(NotifyError<Message<H::Processor, H::Message, H::Response>>),
S... |
}
impl<H: Handler> From<NotifyError<Message<H::Processor, H::Message, H::Response>>> for Error<H> {
fn from(err: NotifyError<Message<H::Processor, H::Message, H::Response>>) -> Error<H> {
Error::NotifyError(err)
}
}
impl<H: Handler> From<SendError<H::Response>> for Error<H> {
fn from(err: SendErr... | {
Error::Io(err)
} | identifier_body |
result.rs | use std::io::Error as IoError;
use std::sync::mpsc::{SendError, RecvError};
use std::result;
use mio::NotifyError;
use queue::Message;
use {Handler};
#[derive(Debug)]
pub enum Error<H: Handler> {
QueueOutOfService,
Io(IoError),
NotifyError(NotifyError<Message<H::Processor, H::Message, H::Response>>),
S... | (err: RecvError) -> Error<H> {
Error::RecvError(err)
}
}
#[derive(Debug)]
pub struct ResponseError(pub &'static str);
pub type ResponseResult<T> = result::Result<T, ResponseError>;
| from | identifier_name |
result.rs | use std::io::Error as IoError;
use std::sync::mpsc::{SendError, RecvError};
use std::result;
use mio::NotifyError;
use queue::Message;
use {Handler};
#[derive(Debug)]
pub enum Error<H: Handler> {
QueueOutOfService,
Io(IoError),
NotifyError(NotifyError<Message<H::Processor, H::Message, H::Response>>),
S... | impl<H: Handler> From<SendError<H::Response>> for Error<H> {
fn from(err: SendError<H::Response>) -> Error<H> {
Error::SendError(err)
}
}
impl<H: Handler> From<RecvError> for Error<H> {
fn from(err: RecvError) -> Error<H> {
Error::RecvError(err)
}
}
#[derive(Debug)]
pub struct Response... | random_line_split | |
var-captured-in-nested-closure.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | {()} | identifier_body | |
var-captured-in-nested-closure.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | // lldb-check:[...]$5 = 7
// lldb-command:print closure_local
// lldb-check:[...]$6 = 8
// lldb-command:continue
// lldb-command:print variable
// lldb-check:[...]$7 = 1
// lldb-command:print constant
// lldb-check:[...]$8 = 2
// lldb-command:print a_struct
// lldb-check:[...]$9 = Struct { a: -3, b: 4.5, c: 5 }
// lld... | // lldb-command:print *struct_ref
// lldb-check:[...]$3 = Struct { a: -3, b: 4.5, c: 5 }
// lldb-command:print *owned
// lldb-check:[...]$4 = 6
// lldb-command:print managed->val | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.