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 |
|---|---|---|---|---|
kmesg_buffer.rs | extern crate errno;
extern crate libc;
#[cfg(target_os = "macos")]
use std::str;
#[cfg(target_os = "macos")]
use self::libc::{c_int, c_void};
#[cfg(target_os = "linux")]
use std::fs::File;
#[cfg(target_os = "linux")]
use std::io::{BufRead, BufReader};
#[cfg(target_os = "linux")]
use std::sync::mpsc;
#[cfg(target_os ... | }
}
/// Get a message (String) from the kernel message ring buffer
/// Turns out that reading to the end of an "infinite file" like "/dev/kmsg" with standard file
/// reading methods will block at the end of file, so a workaround is required. Do the blocking
/// reads on a thread that sends lines read back throug... | {
let mut message_buffer: Vec<u8> = Vec::with_capacity(MAX_MSG_BSIZE);
let buffer_ptr = message_buffer.as_mut_ptr() as *mut c_void;
let ret: i32;
unsafe {
ret = proc_kmsgbuf(buffer_ptr, message_buffer.capacity() as u32);
if ret > 0 {
message_buffer.set_len(ret as usize - 1);... | identifier_body |
kmesg_buffer.rs | extern crate errno;
extern crate libc;
#[cfg(target_os = "macos")]
use std::str;
#[cfg(target_os = "macos")]
use self::libc::{c_int, c_void};
#[cfg(target_os = "linux")]
use std::fs::File;
#[cfg(target_os = "linux")]
use std::io::{BufRead, BufReader};
#[cfg(target_os = "linux")]
use std::sync::mpsc;
#[cfg(target_os ... | () -> Result<String, String> {
let mut message_buffer: Vec<u8> = Vec::with_capacity(MAX_MSG_BSIZE);
let buffer_ptr = message_buffer.as_mut_ptr() as *mut c_void;
let ret: i32;
unsafe {
ret = proc_kmsgbuf(buffer_ptr, message_buffer.capacity() as u32);
if ret > 0 {
message_buff... | kmsgbuf | identifier_name |
p109.rs | //! [Problem 109](https://projecteuler.net/problem=109) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use polynomial::Polynomial;
fn | (score: u32) -> u32 {
let mut single = vec![0u32; 26];
let mut double = vec![0; 51];
let mut triple = vec![0; 61];
let mut dup = vec![0; 121];
for i in 1..21 {
single[i] = 1;
double[i * 2] = 1;
triple[i * 3] = 1;
dup[i * 2] += 1;
dup[i * 4] += 1;
dup[i... | count_way | identifier_name |
p109.rs | //! [Problem 109](https://projecteuler.net/problem=109) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use polynomial::Polynomial;
fn count_way(score: u32) -> u32 {
let mut single = vec![0u32; 26];
let mut doubl... |
}
| {
assert_eq!(11, super::count_way(6));
assert_eq!(42336, super::count_way(171));
} | identifier_body |
p109.rs | //! [Problem 109](https://projecteuler.net/problem=109) solver.
#![warn(
bad_style,
unused,
unused_extern_crates,
unused_import_braces,
unused_qualifications,
unused_results
)]
use polynomial::Polynomial;
fn count_way(score: u32) -> u32 {
let mut single = vec![0u32; 26];
let mut doubl... | let p1 = double.clone();
let p2 = &double * &p_all;
let p3 = &double
* Polynomial::new(
(&p_all * &p_all + &dup)
.data()
.iter()
.map(|&n| n / 2)
.collect(),
);
let total = p1 + p2 + p3;
total.data().iter().take(... |
let p_all = &single + &double + &triple; | random_line_split |
lib.rs | #![feature(try_from)]
#![feature(const_fn)]
#![feature(const_size_of)]
#[macro_use] extern crate log;
extern crate pest;
#[macro_use] extern crate pest_derive;
pub extern crate core;
extern crate machine;
mod var_instr;
mod property;
mod label;
use std::rc::Rc;
use std::io::Write;
use std::borrow::Cow;
use std::mem;... | match var_instr.as_instr(offset, &label_offsets) {
Ok(instr) => {
offset += instr.mem_size();
instructions.push(instr);
},
Err(LabelNotFound(label)) => return Err(Error::CustomErrorSpan {
message: "label not found".into(),
... | let mut offset = 0;
for var_instr in &var_instrs { | random_line_split |
lib.rs | #![feature(try_from)]
#![feature(const_fn)]
#![feature(const_size_of)]
#[macro_use] extern crate log;
extern crate pest;
#[macro_use] extern crate pest_derive;
pub extern crate core;
extern crate machine;
mod var_instr;
mod property;
mod label;
use std::rc::Rc;
use std::io::Write;
use std::borrow::Cow;
use std::mem;... | (name: &str, comment: &str, instrs: &[Instruction], output: &mut Vec<u8>) {
let mut header = Header {
magic: COREWAR_EXEC_MAGIC.to_be(),
prog_name: [0u8; PROG_NAME_LENGTH + 1],
prog_size: (instrs.iter().map(MemSize::mem_size).sum::<usize>() as u32).to_be(),
comment: [0u8; COMMENT_LEN... | raw_compile | identifier_name |
game_core.rs |
use std::io::Write;
use vm::VirtualMachine;
use command::{CommandSystem, UnblockEvent, CommandResult};
use sdl2::render::Renderer;
use sdl2::ttf::Sdl2TtfContext;
use sdl2::event::Event;
use sdl2::keyboard::{Keycode, LCTRLMOD, RCTRLMOD};
use rs6502::Cpu;
pub struct GameCore<'a> {
pub vm: VirtualMachine<'a>,
... | (&mut self) {
if let Some(cmd) = self.vm.console.get_next_command() {
let (result, unblock_event) = self.command_system.execute(cmd, &mut self.vm);
if let CommandResult::NotFound = result {
writeln!(self.vm.console, "Command not recognized, type 'help' for a list of comm... | update | identifier_name |
game_core.rs | use std::io::Write;
use vm::VirtualMachine;
use command::{CommandSystem, UnblockEvent, CommandResult};
use sdl2::render::Renderer;
use sdl2::ttf::Sdl2TtfContext; |
use rs6502::Cpu;
pub struct GameCore<'a> {
pub vm: VirtualMachine<'a>,
pub command_system: CommandSystem,
unblock_event: Option<UnblockEvent>,
}
impl<'a> GameCore<'a> {
pub fn new(ttf_context: &'a Sdl2TtfContext,
mut renderer: &mut Renderer,
font_file: &'a str)
... | use sdl2::event::Event;
use sdl2::keyboard::{Keycode, LCTRLMOD, RCTRLMOD}; | random_line_split |
game_core.rs |
use std::io::Write;
use vm::VirtualMachine;
use command::{CommandSystem, UnblockEvent, CommandResult};
use sdl2::render::Renderer;
use sdl2::ttf::Sdl2TtfContext;
use sdl2::event::Event;
use sdl2::keyboard::{Keycode, LCTRLMOD, RCTRLMOD};
use rs6502::Cpu;
pub struct GameCore<'a> {
pub vm: VirtualMachine<'a>,
... |
pub fn process_event(&mut self, event: &Event) {
match *event {
// Stop a blocking event
Event::KeyDown { keycode, keymod,.. }
if (keycode == Some(Keycode::C) && keymod.intersects(LCTRLMOD | RCTRLMOD) || keycode == Some(Keycode::Return)) &&
self.unblock_e... | {
let cpu = Cpu::new();
let vm = VirtualMachine::new(cpu, 150, &ttf_context, &mut renderer, font_file);
GameCore {
vm: vm,
command_system: CommandSystem::new(),
unblock_event: None,
}
} | identifier_body |
game_core.rs |
use std::io::Write;
use vm::VirtualMachine;
use command::{CommandSystem, UnblockEvent, CommandResult};
use sdl2::render::Renderer;
use sdl2::ttf::Sdl2TtfContext;
use sdl2::event::Event;
use sdl2::keyboard::{Keycode, LCTRLMOD, RCTRLMOD};
use rs6502::Cpu;
pub struct GameCore<'a> {
pub vm: VirtualMachine<'a>,
... |
}
self.vm.cycle();
}
}
| {
self.unblock_event = None;
} | conditional_block |
impl_q_string.rs | use crate::QString;
use cpp_core::CppBox;
use std::os::raw::{c_char, c_int};
/// Allows to convert Qt strings to `std` strings
impl<'a> From<&'a QString> for String {
fn from(s: &'a QString) -> String |
}
impl QString {
/// Creates Qt string from an `std` string.
///
/// `QString` makes a deep copy of the data.
pub fn from_std_str<S: AsRef<str>>(s: S) -> CppBox<QString> {
let slice = s.as_ref().as_bytes();
unsafe { QString::from_utf8_char_int(slice.as_ptr() as *mut c_char, slice.len()... | {
s.to_std_string()
} | identifier_body |
impl_q_string.rs | use crate::QString;
use cpp_core::CppBox;
use std::os::raw::{c_char, c_int};
/// Allows to convert Qt strings to `std` strings
impl<'a> From<&'a QString> for String {
fn | (s: &'a QString) -> String {
s.to_std_string()
}
}
impl QString {
/// Creates Qt string from an `std` string.
///
/// `QString` makes a deep copy of the data.
pub fn from_std_str<S: AsRef<str>>(s: S) -> CppBox<QString> {
let slice = s.as_ref().as_bytes();
unsafe { QString::f... | from | identifier_name |
impl_q_string.rs | use crate::QString;
use cpp_core::CppBox;
use std::os::raw::{c_char, c_int};
/// Allows to convert Qt strings to `std` strings
impl<'a> From<&'a QString> for String {
fn from(s: &'a QString) -> String {
s.to_std_string()
}
}
impl QString {
/// Creates Qt string from an `std` string.
///
//... | } | random_line_split | |
day23.rs | use std::cmp::Reverse;
use std::collections::hash_map::Entry;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::fmt::Display;
use std::io::Read;
use std::mem::swap;
use crate::common::LineIter;
type Item<const S: usize> = (u32, State<S>);
type Todo<const S: usize> = BinaryHeap<Reverse<Item<S>>... | &self.hallway[(pos + 1)..new_hallway_pos]
};
if in_between.iter().any(Option::is_some) {
// Something's in the way
continue;
}
// Check if we can move into the room
if self.rooms[room]
.iter()
... |
// Check if the path is free
let in_between = if new_hallway_pos < pos {
&self.hallway[(new_hallway_pos + 1)..pos]
} else { | random_line_split |
day23.rs | use std::cmp::Reverse;
use std::collections::hash_map::Entry;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::fmt::Display;
use std::io::Read;
use std::mem::swap;
use crate::common::LineIter;
type Item<const S: usize> = (u32, State<S>);
type Todo<const S: usize> = BinaryHeap<Reverse<Item<S>>... | (&self) -> u32 {
// A* estimate. For every entry that is not already "at rest", the cost is the cost
// required to get it to the top of its intended room.
// Cost to enter the hole for all pods that still need to
let enter_estimate: u32 = self
.rooms
.iter()
... | estimate | identifier_name |
day23.rs | use std::cmp::Reverse;
use std::collections::hash_map::Entry;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::fmt::Display;
use std::io::Read;
use std::mem::swap;
use crate::common::LineIter;
type Item<const S: usize> = (u32, State<S>);
type Todo<const S: usize> = BinaryHeap<Reverse<Item<S>>... |
let new_cost = (base_cost + new_pos - hallway_pos) as u32 * pod.cost();
queue_new(new_pos, new_cost);
}
}
}
fn hallway_to_room(&self, cost: u32, todo: &mut Todo<S>, visited: &mut Visited<S>) {
for (pos, pod) in self
.hallway
.i... | {
// Not allowed to stop here
continue;
} | conditional_block |
attributes.rs | // Copyright 2012-2015 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... |
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
#[inline]
pub fn emit_uwtable(val: ValueRef, emit: bool) {
if emit {
llvm::SetFunctionAttribute(val, llvm::Attribute::UWTable);
} else {
unsafe {
llvm::LLVMRemoveFunctionAttr(
... | {
use self::InlineAttr::*;
match inline {
Hint => llvm::SetFunctionAttribute(val, llvm::Attribute::InlineHint),
Always => llvm::SetFunctionAttribute(val, llvm::Attribute::AlwaysInline),
Never => llvm::SetFunctionAttribute(val, llvm::Attribute::NoInline),
None => {
... | identifier_body |
attributes.rs | // Copyright 2012-2015 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... | }
}
for &t in input_tys.iter() {
match t.sty {
_ if type_of::arg_is_indirect(ccx, t) => {
let llarg_sz = machine::llsize_of_real(ccx, type_of::type_of(ccx, t));
// For non-immediate arguments the callee gets its own copy of
// the val... | } | random_line_split |
attributes.rs | // Copyright 2012-2015 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... | (ccx: &CrateContext, attrs: &[ast::Attribute], llfn: ValueRef) {
use syntax::attr::*;
inline(llfn, find_inline_attr(Some(ccx.sess().diagnostic()), attrs));
// FIXME: #11906: Omitting frame pointers breaks retrieving the value of a
// parameter.
let no_fp_elim = (ccx.sess().opts.debuginfo!= NoDebugI... | from_fn_attrs | identifier_name |
attributes.rs | // Copyright 2012-2015 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... |
}
}
for &t in input_tys.iter() {
match t.sty {
_ if type_of::arg_is_indirect(ccx, t) => {
let llarg_sz = machine::llsize_of_real(ccx, type_of::type_of(ccx, t));
// For non-immediate arguments the callee gets its own copy of
// the va... | {
attrs.ret(llvm::Attribute::ZExt);
} | conditional_block |
path.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | }
}
/// Restricts the permissions of given path only to the owner.
#[cfg(not(windows))]
pub fn restrict_permissions_owner(file_path: &Path) -> Result<(), i32> {
let cstr = ::std::ffi::CString::new(file_path.to_str().unwrap()).unwrap();
match unsafe { ::libc::chmod(cstr.as_ptr(), ::libc::S_IWUSR | ::libc::S_IRUSR) ... | path.push(s);
path | random_line_split |
path.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... |
/// Restricts the permissions of given path only to the owner.
#[cfg(windows)]
pub fn restrict_permissions_owner(_file_path: &Path) -> Result<(), i32> {
//TODO: implement me
Ok(())
}
| {
let cstr = ::std::ffi::CString::new(file_path.to_str().unwrap()).unwrap();
match unsafe { ::libc::chmod(cstr.as_ptr(), ::libc::S_IWUSR | ::libc::S_IRUSR) } {
0 => Ok(()),
x => Err(x),
}
} | identifier_body |
path.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | (s: &str) -> PathBuf {
let mut path = default();
path.push("testnet");
path.push(s);
path
}
}
/// Restricts the permissions of given path only to the owner.
#[cfg(not(windows))]
pub fn restrict_permissions_owner(file_path: &Path) -> Result<(), i32> {
let cstr = ::std::ffi::CString::new(file_path.to_str().un... | with_testnet | identifier_name |
gcalendar.rs | // Copyright 2013 Luis de Bethencourt <luis@debethencourt.com>
// Copyright 2013 The Rust Project Developers
// http://rust-lang.org
// 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 http://opensource.org/licenses/M... |
pub fn get_day_of_month(&self) -> uint {
self.mday
}
pub fn get_month(&self) -> uint {
self.month
}
pub fn get_year(&self) -> uint {
self.year
}
pub fn get_day_of_week(&self) -> uint {
self.wday
}
pub fn get_day_of_year(&self) -> uint {
s... | {
self.hour
} | identifier_body |
gcalendar.rs | // Copyright 2013 Luis de Bethencourt <luis@debethencourt.com>
// Copyright 2013 The Rust Project Developers
// http://rust-lang.org
// 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 http://opensource.org/licenses/M... | y -= 1;
}
let years = (year1 - year0);
let days = 365 * years + yday1 - yday0 + intervening_leap_days;
let hours = 24 * days + hour1 - hour0;
let minutes = 60 * hours + min1 - min0;
60 * minutes + sec1 - sec0
}
pub fn mktime(&self) -> uint {
... | while (y > year0) {
if is_leap_year(y) {intervening_leap_days += 1;} | random_line_split |
gcalendar.rs | // Copyright 2013 Luis de Bethencourt <luis@debethencourt.com>
// Copyright 2013 The Rust Project Developers
// http://rust-lang.org
// 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 http://opensource.org/licenses/M... | (&self, year1: uint, yday1: uint, hour1: uint, min1: uint,
sec1: uint, year0: uint, yday0: uint, hour0: uint,
min0: uint, sec0: uint) -> uint {
/* Return an integer value measuring (YEAR1-YDAY1 HOUR1:MIN1:SEC1) -
* (YEAR0-YDAY0 HOUR0:MIN0:SEC0) in seconds.
... | ydhms_diff | identifier_name |
gcalendar.rs | // Copyright 2013 Luis de Bethencourt <luis@debethencourt.com>
// Copyright 2013 The Rust Project Developers
// http://rust-lang.org
// 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 http://opensource.org/licenses/M... |
'd' => format!("{:02u}", self.mday),
'e' => format!("{:2u}", self.mday),
'f' => format!("{:09u}", self.sec),
'F' => {
format!("{}-{}-{}",
self.get_date('Y'),
self.get_date('m'),
self.get_date(... | {
format!("{}/{}/{}",
self.get_date('m'),
self.get_date('d'),
self.get_date('y'))
} | conditional_block |
robinhood.rs | // TODO: says premature end of input
// use chrono::{DateTime, NaiveDateTime};
// use chrono::offset::Utc;
use futures::{future, Future, Stream};
use hyper::{client::HttpConnector, Body, Client};
use hyper_tls::HttpsConnector;
use serde_derive::{Deserialize, Serialize};
use serde_json;
type HttpsClient = Client<HttpsC... | {
results: Vec<Quote>,
}
pub fn get_quotes(
client: &HttpsClient,
symbols: &Vec<String>,
) -> impl Future<Item = Quotes, Error = ()> {
let query = &symbols.join(",").to_uppercase();
let url = format!("https://api.robinhood.com/quotes/?symbols={}", query);
client
.get(url.parse().unwrap(... | Quotes | identifier_name |
robinhood.rs | // TODO: says premature end of input
// use chrono::{DateTime, NaiveDateTime};
// use chrono::offset::Utc;
use futures::{future, Future, Stream};
use hyper::{client::HttpConnector, Body, Client};
use hyper_tls::HttpsConnector;
use serde_derive::{Deserialize, Serialize};
use serde_json;
type HttpsClient = Client<HttpsC... | last_extended_hours_trade_price: String,
last_trade_price: String,
last_trade_price_source: String,
previous_close: String,
previous_close_date: String,
symbol: String,
trading_halted: bool,
updated_at: String,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Quotes {
results: ... | // TODO: can this be a URL? needs to implement Serde's deserialize
instrument: String, | random_line_split |
regions-infer-invariance-due-to-mutability-4.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 ... | <'a> {
f:'static || -> &mut &'a int
}
fn to_same_lifetime<'r>(bi: invariant<'r>) {
let bj: invariant<'r> = bi;
}
fn to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
bi //~ ERROR mismatched types
}
fn main() {
}
| invariant | identifier_name |
regions-infer-invariance-due-to-mutability-4.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 to_longer_lifetime<'r>(bi: invariant<'r>) -> invariant<'static> {
bi //~ ERROR mismatched types
}
fn main() {
}
| {
let bj: invariant<'r> = bi;
} | identifier_body |
rtcerror.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 https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::RTCErrorDetailType;
use crate::dom::bindings::codeg... | }
// https://www.w3.org/TR/webrtc/#dom-rtcerror-sctpcausecode
fn GetSctpCauseCode(&self) -> Option<i32> {
self.sctp_cause_code
}
// https://www.w3.org/TR/webrtc/#dom-rtcerror-receivedalert
fn GetReceivedAlert(&self) -> Option<u32> {
self.received_alert
}
// https://www... |
// https://www.w3.org/TR/webrtc/#dom-rtcerror
fn GetHttpRequestStatusCode(&self) -> Option<i32> {
self.http_request_status_code | random_line_split |
rtcerror.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 https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::RTCErrorDetailType;
use crate::dom::bindings::codeg... |
}
| {
self.sent_alert
} | identifier_body |
rtcerror.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 https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::codegen::Bindings::RTCErrorBinding::RTCErrorDetailType;
use crate::dom::bindings::codeg... | (&self) -> RTCErrorDetailType {
self.error_detail
}
// https://www.w3.org/TR/webrtc/#dom-rtcerror-sdplinenumber
fn GetSdpLineNumber(&self) -> Option<i32> {
self.sdp_line_number
}
// https://www.w3.org/TR/webrtc/#dom-rtcerror
fn GetHttpRequestStatusCode(&self) -> Option<i32> {
... | ErrorDetail | identifier_name |
fmt-pointer-trait.rs | // Copyright 2015 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!(format!("{:p}", p),
"0x0");
}
| {
assert_eq!(format!("{:#p}", p),
"0x0000000000000000");
} | conditional_block |
fmt-pointer-trait.rs | // Copyright 2015 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 p: *const libc::c_void = ptr::null();
let rc = Rc::new(1usize);
let arc = Arc::new(1usize);
let b = Box::new("hi");
let _ = format!("{:p}{:p}{:p}",
rc, arc, b);
if cfg!(target_pointer_width = "32") {
assert_eq!(format!("{:#p}", p),
"0x000000... | identifier_body | |
fmt-pointer-trait.rs | // Copyright 2015 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 ... | use std::rc::Rc;
use std::sync::Arc;
fn main() {
let p: *const libc::c_void = ptr::null();
let rc = Rc::new(1usize);
let arc = Arc::new(1usize);
let b = Box::new("hi");
let _ = format!("{:p}{:p}{:p}",
rc, arc, b);
if cfg!(target_pointer_width = "32") {
assert_eq!(f... | random_line_split | |
fmt-pointer-trait.rs | // Copyright 2015 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 p: *const libc::c_void = ptr::null();
let rc = Rc::new(1usize);
let arc = Arc::new(1usize);
let b = Box::new("hi");
let _ = format!("{:p}{:p}{:p}",
rc, arc, b);
if cfg!(target_pointer_width = "32") {
assert_eq!(format!("{:#p}", p),
"0x000... | main | identifier_name |
Canonical_Const.rs | endogenous DPQ_P_NW "Inflation", Y, ZGDP, ZI, ZPAI, ZY, D_GDP_NW "Growth", I, PAI, R, RN3M_NW "Fed Funds Rate" | gam_lag "\gamma_{lag}", gam_y "\gamma_{y}", gyss, iss, lamb_lag "\lambda_{lag}",
lamb_lead "\lambda_{lead}", lamb_y "\lambda_{y}", paiss,
rhogdp "\rho_{gdp}", rhoi "\rho_{i}", rhopai "\rho_{\pi}", rhoy "\rho_{y}",
siggdp "\sigma_{gdp}", sigi "\sigma_{i}", sigpai "\sigma_{\pi}", sigy "\sigma_{y}"
model
# junk=beta_le... |
exogenous EGDP "output shock",EI "monetary policy shock",EPAI "Cost push shock",EY "IS shock"
parameters beta_lag "\beta_{lag}", beta_lead "\beta_{lead}", beta_r "\beta_{r}", | random_line_split |
windowproxy.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/. */
use dom::bindings::codegen::WindowProxyBinding;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable,... |
#[deriving(Encodable)]
pub struct WindowProxy {
reflector_: Reflector
}
impl WindowProxy {
pub fn new(owner: &JS<Window>) -> JS<WindowProxy> {
let proxy = ~WindowProxy {
reflector_: Reflector::new()
};
reflect_dom_object(proxy, owner, WindowProxyBinding::Wrap)
}
}
impl... | random_line_split | |
windowproxy.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/. */
use dom::bindings::codegen::WindowProxyBinding;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable,... | {
reflector_: Reflector
}
impl WindowProxy {
pub fn new(owner: &JS<Window>) -> JS<WindowProxy> {
let proxy = ~WindowProxy {
reflector_: Reflector::new()
};
reflect_dom_object(proxy, owner, WindowProxyBinding::Wrap)
}
}
impl Reflectable for WindowProxy {
fn reflecto... | WindowProxy | identifier_name |
windowproxy.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/. */
use dom::bindings::codegen::WindowProxyBinding;
use dom::bindings::js::JS;
use dom::bindings::utils::{Reflectable,... |
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
&mut self.reflector_
}
}
| {
&self.reflector_
} | identifier_body |
min_const_unsafe_fn_libstd_stability2.rs | // Copyright 2018 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 ... | //~ ERROR can only call other `min_const_fn`
// check whether this function cannot be called even with the feature gate active
#[unstable(feature = "foo2", issue="0")]
const fn foo2_gated() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
const unsafe fn bar2_gated() -> u32 ... | { foo2() } | identifier_body |
min_const_unsafe_fn_libstd_stability2.rs | // Copyright 2018 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 ... | const fn foo() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
// can't call non-min_const_fn
const unsafe fn bar() -> u32 { foo() } //~ ERROR can only call other `min_const_fn`
#[unstable(feature = "rust1", issue="0")]
const fn foo2() -> u32 { 42 }
#[stable(feature = "rust1", since = "1.0.0")]
// can't ... | random_line_split | |
min_const_unsafe_fn_libstd_stability2.rs | // Copyright 2018 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 |
f31-sigtstp-handler.rs | /// Figure 10.31 How to handle SIGTSTP
///
/// Added a println to sig_tstp to show that the signal
/// is really caught
#[macro_use(as_void)]
extern crate apue;
extern crate libc;
use std::mem::uninitialized;
use std::ptr::null_mut;
use libc::{c_int, SIGTSTP, SIG_UNBLOCK, SIG_DFL, SIG_IGN, STDIN_FILENO, STDOUT_FILENO}... | () {
unsafe {
if signal(SIGTSTP, SIG_IGN) == SIG_DFL {
signal(SIGTSTP, sig_tstp as usize);
}
let buf = vec![0; BUFFSIZE];
while let Ok(n) = read(STDIN_FILENO, as_void!(buf), BUFFSIZE).check_positive() {
if write(STDOUT_FILENO, as_void!(buf), n as _)!= n {
... | main | identifier_name |
f31-sigtstp-handler.rs | /// Figure 10.31 How to handle SIGTSTP
///
/// Added a println to sig_tstp to show that the signal
/// is really caught
#[macro_use(as_void)]
extern crate apue;
extern crate libc;
use std::mem::uninitialized;
use std::ptr::null_mut;
use libc::{c_int, SIGTSTP, SIG_UNBLOCK, SIG_DFL, SIG_IGN, STDIN_FILENO, STDOUT_FILENO}... |
fn main() {
unsafe {
if signal(SIGTSTP, SIG_IGN) == SIG_DFL {
signal(SIGTSTP, sig_tstp as usize);
}
let buf = vec![0; BUFFSIZE];
while let Ok(n) = read(STDIN_FILENO, as_void!(buf), BUFFSIZE).check_positive() {
if write(STDOUT_FILENO, as_void!(buf), n as _)!=... | {
// move cursor to lower left corner, reset tty mode
// unblock SIGTSTP, since it's blocked while we're reading it
println!("last cleanup before SIGTSTP");
let mut mask = uninitialized();
sigemptyset(&mut mask);
sigaddset(&mut mask, SIGTSTP);
sigprocmask(SIG_UNBLOCK, &mask, null_mut());
... | identifier_body |
f31-sigtstp-handler.rs | /// Figure 10.31 How to handle SIGTSTP
///
/// Added a println to sig_tstp to show that the signal
/// is really caught
#[macro_use(as_void)]
extern crate apue;
extern crate libc;
use std::mem::uninitialized;
use std::ptr::null_mut;
use libc::{c_int, SIGTSTP, SIG_UNBLOCK, SIG_DFL, SIG_IGN, STDIN_FILENO, STDOUT_FILENO}... |
let buf = vec![0; BUFFSIZE];
while let Ok(n) = read(STDIN_FILENO, as_void!(buf), BUFFSIZE).check_positive() {
if write(STDOUT_FILENO, as_void!(buf), n as _)!= n {
err_sys("write error");
}
}
}
}
| {
signal(SIGTSTP, sig_tstp as usize);
} | conditional_block |
f31-sigtstp-handler.rs | /// Figure 10.31 How to handle SIGTSTP
///
/// Added a println to sig_tstp to show that the signal
/// is really caught
#[macro_use(as_void)]
extern crate apue;
extern crate libc;
use std::mem::uninitialized; | use std::ptr::null_mut;
use libc::{c_int, SIGTSTP, SIG_UNBLOCK, SIG_DFL, SIG_IGN, STDIN_FILENO, STDOUT_FILENO};
use libc::{sigemptyset, sigaddset, signal, kill, getpid, read, write};
use apue::my_libc::sigprocmask;
use apue::{LibcResult, err_sys};
const BUFFSIZE: usize = 1024;
unsafe fn sig_tstp(_: c_int) {
// mo... | random_line_split | |
response.rs | use hyper::header::{self, CookiePair as Cookie, ContentType, Header, SetCookie};
use hyper::status::StatusCode as Status;
use hyper::Headers;
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
use serde_json::value as json;
use serde_json::value::ToJson;
use std::any::Any;
use std::boxed::Box;
use std::borrow... | <S: Into<String>>(&mut self, url: S) -> &mut Self {
self.headers.set(header::Location(url.into()));
self
}
/// Sends the given file, setting the Content-Type based on the file's extension.
///
/// Known extensions are:
/// - application: js, m3u8, mpd, xml
/// - image: gif, ... | location | identifier_name |
response.rs | use hyper::header::{self, CookiePair as Cookie, ContentType, Header, SetCookie};
use hyper::status::StatusCode as Status;
use hyper::Headers;
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
use serde_json::value as json;
use serde_json::value::ToJson;
use std::any::Any;
use std::boxed::Box;
use std::borrow... |
impl From<(Status, &'static str)> for Error {
fn from(pair: (Status, &'static str)) -> Error {
Error::new(pair.0, Some(Cow::Borrowed(pair.1)))
}
}
impl From<(Status, String)> for Error {
fn from(pair: (Status, String)) -> Error {
Error::new(pair.0, Some(Cow::Owned(pair.1)))
}
}
/// De... | } | random_line_split |
response.rs | use hyper::header::{self, CookiePair as Cookie, ContentType, Header, SetCookie};
use hyper::status::StatusCode as Status;
use hyper::Headers;
use hyper::mime::{Mime, TopLevel, SubLevel, Attr, Value};
use serde_json::value as json;
use serde_json::value::ToJson;
use std::any::Any;
use std::boxed::Box;
use std::borrow... |
}
/// Conversion from `json::Value` into `Action::Send(bytes)`.
impl From<json::Value> for Action {
fn from(json: json::Value) -> Action {
From::from(json.to_string())
}
}
/// Wraps the given closure in a box and returns `Ok(Action::Stream(box))`.
///
/// The closure will be called with a writer impl... | {
Action::Send(string.into_bytes())
} | identifier_body |
ext.rs | // Copyright (C) 2016, Alberto Corona <ac@albertocorona.com>
// All rights reserved. This file is part of libpm, distributed under the
// BSD 3-clause license. For full terms please see the LICENSE file.
extern crate toml;
use error::PkgError;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::path::{... |
#[test]
fn test_clean_path() {
let test_path = PathBuf::from("test/pkg/dir");
assert_eq!(clean_path(test_path), PathBuf::from("test/dir"));
}
| {
let mut buff = String::new();
let mut file = match File::open(file) {
Ok(s) => s,
Err(e) => {
return Err(PkgError::Io(e));
}
};
match file.read_to_string(&mut buff) {
Ok(s) => s,
Err(e) => {
return Err(PkgError::Io(e));
}
};
... | identifier_body |
ext.rs | // Copyright (C) 2016, Alberto Corona <ac@albertocorona.com>
// All rights reserved. This file is part of libpm, distributed under the
// BSD 3-clause license. For full terms please see the LICENSE file.
extern crate toml;
use error::PkgError;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::path::{... | let test_path = PathBuf::from("test/pkg/dir");
assert_eq!(clean_path(test_path), PathBuf::from("test/dir"));
} | }
#[test]
fn test_clean_path() { | random_line_split |
ext.rs | // Copyright (C) 2016, Alberto Corona <ac@albertocorona.com>
// All rights reserved. This file is part of libpm, distributed under the
// BSD 3-clause license. For full terms please see the LICENSE file.
extern crate toml;
use error::PkgError;
use std::fs;
use std::fs::File;
use std::io::prelude::*;
use std::path::{... | <T: AsRef<Path>>(file: T) -> Result<toml::Value, PkgError> {
let mut buff = String::new();
let mut file = match File::open(file) {
Ok(s) => s,
Err(e) => {
return Err(PkgError::Io(e));
}
};
match file.read_to_string(&mut buff) {
Ok(s) => s,
Err(e) => {
... | parse_toml_file | identifier_name |
trait-bounds-in-arc.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... | use std::task;
trait Pet {
fn name(&self, blk: |&str|);
fn num_legs(&self) -> uint;
fn of_good_pedigree(&self) -> bool;
}
struct Catte {
num_whiskers: uint,
name: StrBuf,
}
struct Dogge {
bark_decibels: uint,
tricks_known: uint,
name: StrBuf,
}
struct Goldfyshe {
swim_speed: uint... |
extern crate sync;
use sync::Arc; | random_line_split |
trait-bounds-in-arc.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... |
}
impl Pet for Goldfyshe {
fn name(&self, blk: |&str|) { blk(self.name.as_slice()) }
fn num_legs(&self) -> uint { 0 }
fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
}
pub fn main() {
let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_strbuf() };
let dogge1 = Dogge {
... | {
self.bark_decibels < 70 || self.tricks_known > 20
} | identifier_body |
trait-bounds-in-arc.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... | (&self) -> uint { 0 }
fn of_good_pedigree(&self) -> bool { self.swim_speed >= 500 }
}
pub fn main() {
let catte = Catte { num_whiskers: 7, name: "alonzo_church".to_strbuf() };
let dogge1 = Dogge {
bark_decibels: 100,
tricks_known: 42,
name: "alan_turing".to_strbuf(),
};
let ... | num_legs | identifier_name |
assign-to-method.rs | // Copyright 2012 The Rust Project Developers. See the 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 http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct cat {
priv... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
assign-to-method.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 cat(in_x : uint, in_y : int) -> cat {
cat {
meows: in_x,
how_hungry: in_y
}
}
fn main() {
let nyan : cat = cat(52u, 99);
nyan.speak = || info!("meow"); //~ ERROR attempted to take value of method
}
| { self.meows += 1u; } | identifier_body |
assign-to-method.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 ... | (in_x : uint, in_y : int) -> cat {
cat {
meows: in_x,
how_hungry: in_y
}
}
fn main() {
let nyan : cat = cat(52u, 99);
nyan.speak = || info!("meow"); //~ ERROR attempted to take value of method
}
| cat | identifier_name |
simple-struct-min-capture.rs | // edition:2021
#![feature(rustc_attrs)]
// Test to ensure that min analysis meets capture kind for all paths captured.
| #[derive(Debug)]
struct Point {
x: i32,
y: i32,
}
fn main() {
let mut p = Point { x: 10, y: 20 };
//
// Requirements:
// p.x -> MutBoorrow
// p -> ImmBorrow
//
// Requirements met when p is captured via MutBorrow
//
let mut c = #[rustc_capture_analysis]
//~^ ERROR... | random_line_split | |
simple-struct-min-capture.rs | // edition:2021
#![feature(rustc_attrs)]
// Test to ensure that min analysis meets capture kind for all paths captured.
#[derive(Debug)]
struct Point {
x: i32,
y: i32,
}
fn | () {
let mut p = Point { x: 10, y: 20 };
//
// Requirements:
// p.x -> MutBoorrow
// p -> ImmBorrow
//
// Requirements met when p is captured via MutBorrow
//
let mut c = #[rustc_capture_analysis]
//~^ ERROR: attributes on expressions are experimental
//~| NOTE: se... | main | identifier_name |
build.rs | extern crate ffigen;
extern crate msbuild_util;
use std::process::Command;
use std::fs;
use std::env;
fn main() {
let mut context = ffigen::Context::new();
context.set_root("../scaffold".to_string());
context.add_lang(ffigen::Lang::CSharp, &[ffigen::Config::Output(".".to_string())]);
ffigen::gen(&co... |
#[cfg(not(target_os = "windows"))]
fn get_output_lib(name: &str) -> String {
format!("lib{}.so", name)
}
fn build(config: &String) {
let msbuild = msbuild_util::MSBuild::new()
.project("CSharp.csproj")
.platform(msbuild_util::Platform::X64)
.config(match config.as_ref() {
"debug"... |
#[cfg(target_os = "windows")]
fn get_output_lib(name: &str) -> String {
format!("{}.dll", name)
} | random_line_split |
build.rs | extern crate ffigen;
extern crate msbuild_util;
use std::process::Command;
use std::fs;
use std::env;
fn main() {
let mut context = ffigen::Context::new();
context.set_root("../scaffold".to_string());
context.add_lang(ffigen::Lang::CSharp, &[ffigen::Config::Output(".".to_string())]);
ffigen::gen(&co... | (config: &String) {
let msbuild = msbuild_util::MSBuild::new()
.project("CSharp.csproj")
.platform(msbuild_util::Platform::X64)
.config(match config.as_ref() {
"debug" => msbuild_util::Config::Debug,
"release" => msbuild_util::Config::Release,
cfg => panic!("... | build | identifier_name |
build.rs | extern crate ffigen;
extern crate msbuild_util;
use std::process::Command;
use std::fs;
use std::env;
fn main() {
let mut context = ffigen::Context::new();
context.set_root("../scaffold".to_string());
context.add_lang(ffigen::Lang::CSharp, &[ffigen::Config::Output(".".to_string())]);
ffigen::gen(&co... |
fn build(config: &String) {
let msbuild = msbuild_util::MSBuild::new()
.project("CSharp.csproj")
.platform(msbuild_util::Platform::X64)
.config(match config.as_ref() {
"debug" => msbuild_util::Config::Debug,
"release" => msbuild_util::Config::Release,
cfg =... | {
format!("lib{}.so", name)
} | identifier_body |
lib.rs | PartialEq, Eq, Hash)]
pub struct UntrustedNodeAddress(pub *const c_void);
impl HeapSizeOf for UntrustedNodeAddress {
fn heap_size_of_children(&self) -> usize {
0
}
}
#[allow(unsafe_code)]
unsafe impl Send for UntrustedNodeAddress {}
impl Serialize for UntrustedNodeAddress {
fn serialize<S: Seria... | ConstellationMsg | identifier_name | |
lib.rs | , ResourceThreads};
use net_traits::image::base::Image;
use net_traits::image_cache::ImageCache;
use net_traits::response::HttpsState;
use net_traits::storage_thread::StorageType;
use profile_traits::mem;
use profile_traits::time as profile_time;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use servo_... | Fatal,
}
impl MozBrowserErrorType {
/// Get the name of the error type as a `& str`
pub fn name(&self) -> &'static str {
match *self {
MozBrowserErrorType::Fatal => "fatal",
}
}
}
/// Specifies whether the script or layout thread needs to be ticked for animation.
#[derive(D... | /// A fatal error | random_line_split |
class-poly-methods-cross-crate.rs | // Copyright 2012-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... | () {
let mut nyan : cat<char> = cat::<char>(52_usize, 99, vec!('p'));
let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1_usize,2_usize,3_usize));
assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!("meow"... | main | identifier_name |
class-poly-methods-cross-crate.rs | // Copyright 2012-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... | assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1_usize,2_usize,3_usize));
assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!("meow".to_string(), "mew".to_string(), "purr".to_string(), "chirp".to_string()));
assert_eq!(kitty.meow_count(), 1004_usize);
} | let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99); | random_line_split |
class-poly-methods-cross-crate.rs | // Copyright 2012-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... | {
let mut nyan : cat<char> = cat::<char>(52_usize, 99, vec!('p'));
let mut kitty = cat(1000_usize, 2, vec!("tabby".to_string()));
assert_eq!(nyan.how_hungry, 99);
assert_eq!(kitty.how_hungry, 2);
nyan.speak(vec!(1_usize,2_usize,3_usize));
assert_eq!(nyan.meow_count(), 55_usize);
kitty.speak(vec!("meow".to... | identifier_body | |
lexical-scope-in-if.rs | // Copyright 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-MIT or ... |
zzz();
sentinel();
if x > 1000 {
unreachable!();
} else {
zzz();
sentinel();
let x = 1004;
let y = 1005;
zzz();
sentinel();
}
zzz();
sentinel();
}
fn zzz() {()}
fn sentinel() {()}
| {
unreachable!();
} | conditional_block |
lexical-scope-in-if.rs | // Copyright 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-MIT or ... | }
fn zzz() {()}
fn sentinel() {()} | random_line_split | |
lexical-scope-in-if.rs | // Copyright 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-MIT or ... | () {
let x = 999;
let y = -1;
zzz();
sentinel();
if x < 1000 {
zzz();
sentinel();
let x = 1001;
zzz();
sentinel();
let x = 1002;
let y = 1003;
zzz();
sentinel();
} else {
unreachable!();
}
zzz();
s... | main | identifier_name |
lexical-scope-in-if.rs | // Copyright 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-MIT or ... | sentinel();
} else {
unreachable!();
}
zzz();
sentinel();
if x > 1000 {
unreachable!();
} else {
zzz();
sentinel();
let x = 1004;
let y = 1005;
zzz();
sentinel();
}
zzz();
sentinel();
}
fn zzz() {()}
fn sen... | {
let x = 999;
let y = -1;
zzz();
sentinel();
if x < 1000 {
zzz();
sentinel();
let x = 1001;
zzz();
sentinel();
let x = 1002;
let y = 1003;
zzz(); | identifier_body |
build.rs | // Copyright 2019 Google LLC | // 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 agreed to in writing, software
// distributed... | // | random_line_split |
build.rs | // Copyright 2019 Google LLC
//
// 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 agreed to in ... | () {
println!("cargo:rerun-if-changed=crypto_data/aaguid.txt");
let out_dir = env::var_os("OUT_DIR").unwrap();
let aaguid_bin_path = Path::new(&out_dir).join("opensk_aaguid.bin");
let mut aaguid_bin_file = File::create(&aaguid_bin_path).unwrap();
let mut aaguid_txt_file = File::open("crypto_data/a... | main | identifier_name |
build.rs | // Copyright 2019 Google LLC
//
// 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 agreed to in ... | {
println!("cargo:rerun-if-changed=crypto_data/aaguid.txt");
let out_dir = env::var_os("OUT_DIR").unwrap();
let aaguid_bin_path = Path::new(&out_dir).join("opensk_aaguid.bin");
let mut aaguid_bin_file = File::create(&aaguid_bin_path).unwrap();
let mut aaguid_txt_file = File::open("crypto_data/aagu... | identifier_body | |
eq.rs | // Copyright 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-MIT or ... | (cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span, substr)
}
fn cs_ne(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_or(|cx, span, _, _| cx.expr_bool(span, true),
... | cs_eq | identifier_name |
eq.rs | // Copyright 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-MIT or ... | args: vec!(borrowed_self()),
ret_ty: Literal(Path::new(vec!("bool"))),
attributes: attrs,
const_nonmatching: true,
combine_substructure: combine_substructure(|a, b, c| {
$f(a, b, c)
})
}
... | {
// structures are equal if all fields are equal, and non equal, if
// any fields are not equal or if the enum variants are different
fn cs_eq(cx: &mut ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
cs_and(|cx, span, _, _| cx.expr_bool(span, false),
cx, span... | identifier_body |
eq.rs | // Copyright 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-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ast::{MetaItem, Item, Expr};
use codemap::Span;
use ext::base::ExtCtxt;
use ext::bui... | random_line_split | |
main.rs | ///! GIT REQ!
mod git;
mod remotes;
use anyhow::Result;
use clap::{crate_authors, crate_version, App, AppSettings, ArgMatches, YamlLoader};
use colored::*;
use git2::ErrorCode;
use lazy_static::lazy_static;
use log::{debug, error, info, trace};
use std::io::{self, stdin, stdout, Cursor, Write};
use std::{env, include_... | (message: &str) ->! {
eprintln!("{}", message.red());
process::exit(1);
}
/// Get the remote for the current project
fn get_remote(remote_name: &str, fetch_api_key: bool) -> Result<Box<dyn remotes::Remote>> {
let remote_url = git::get_remote_url(remote_name);
remotes::get_remote(remote_name, &remote_ur... | abort | identifier_name |
main.rs | ///! GIT REQ!
mod git;
mod remotes;
use anyhow::Result;
use clap::{crate_authors, crate_version, App, AppSettings, ArgMatches, YamlLoader};
use colored::*;
use git2::ErrorCode;
use lazy_static::lazy_static;
use log::{debug, error, info, trace};
use std::io::{self, stdin, stdout, Cursor, Write};
use std::{env, include_... | else if let Some(shell_name) = matches.value_of("GENERATE_COMPLETIONS") {
app = build_cli();
generate_completion(&mut app, &shell_name);
} else {
let request_id = matches.value_of("REQUEST_ID").unwrap();
let mr_id = if request_id == "-" {
trace!("Received request for pre... | {
set_default_remote(remote_name);
} | conditional_block |
main.rs | ///! GIT REQ!
mod git;
mod remotes;
use anyhow::Result;
use clap::{crate_authors, crate_version, App, AppSettings, ArgMatches, YamlLoader};
use colored::*;
use git2::ErrorCode;
use lazy_static::lazy_static;
use log::{debug, error, info, trace};
use std::io::{self, stdin, stdout, Cursor, Write};
use std::{env, include_... |
/// Set the default remote for the repository
fn set_default_remote(remote_name: &str) {
trace!("Setting default remote {}", remote_name);
git::set_project_config("defaultremote", remote_name);
eprintln!("{}", "New default remote set!".green());
}
/// Print the open requests
fn list_open_requests(remote_... | {
trace!("Setting project ID: {} for remote: {}", new_id, remote_name);
git::set_config("projectid", remote_name, new_id);
eprintln!("{}", "New project ID set!".green());
} | identifier_body |
main.rs | ///! GIT REQ!
mod git;
mod remotes;
use anyhow::Result;
use clap::{crate_authors, crate_version, App, AppSettings, ArgMatches, YamlLoader};
use colored::*;
use git2::ErrorCode;
use lazy_static::lazy_static;
use log::{debug, error, info, trace};
use std::io::{self, stdin, stdout, Cursor, Write};
use std::{env, include_... | &error
);
abort(&message);
})
}
/// Check out the branch corresponding to the MR ID and the remote's name
fn checkout_mr(remote_name: &str, mr_id: i64) {
info!("Getting MR: {}", mr_id);
let mut remote = get_remote_hard(remote_name, true);
debug!("Found remote: {}", remote);
... | random_line_split | |
rustbenchs.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... | {
let mut tester = MyTester {};
run_suite!(tester, bboxlist::run);
run_suite!(tester, bdlist::run);
run_suite!(tester, bmgate::run);
run_suite!(tester, bpipe::run);
run_suite!(tester, bregfile::run);
run_suite!(tester, bstream::run);
run_suite!(tester, bsyscall::run);
run_suite!(test... | identifier_body | |
rustbenchs.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... | () -> i32 {
let mut tester = MyTester {};
run_suite!(tester, bboxlist::run);
run_suite!(tester, bdlist::run);
run_suite!(tester, bmgate::run);
run_suite!(tester, bpipe::run);
run_suite!(tester, bregfile::run);
run_suite!(tester, bstream::run);
run_suite!(tester, bsyscall::run);
run_s... | main | identifier_name |
rustbenchs.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... | println!("Done\n");
}
fn run_test(&mut self, name: &str, f: &Fn()) {
println!("-- Running benchmark {}...", name);
let free_mem = m3::heap::free_memory();
f();
assert_eq!(m3::heap::free_memory(), free_mem);
println!("-- Done");
}
}
#[no_mangle]
pub fn main()... | impl Tester for MyTester {
fn run_suite(&mut self, name: &str, f: &Fn(&mut Tester)) {
println!("Running benchmark suite {} ...", name);
f(self); | random_line_split |
accounts.rs | #![allow(unused_variables)]
use domain::Money;
use rocket_contrib::{JSON, UUID};
use uuid::Uuid;
#[derive(Debug, Copy, Clone, Deserialize)]
pub struct OpenAccountData {
pub initial_balance: Money,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DepositMoneyData {
pub transfer_id: Uuid,
pub amount: Mone... | pub fn close_account(id: UUID) {
unimplemented!()
} | random_line_split | |
accounts.rs | #![allow(unused_variables)]
use domain::Money;
use rocket_contrib::{JSON, UUID};
use uuid::Uuid;
#[derive(Debug, Copy, Clone, Deserialize)]
pub struct OpenAccountData {
pub initial_balance: Money,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DepositMoneyData {
pub transfer_id: Uuid,
pub amount: Mone... | {
pub transfer_id: Uuid,
pub amount: Money,
}
#[post("/accounts", data = "<data>")]
pub fn open_account(data: JSON<OpenAccountData>) {
unimplemented!()
}
#[post("/accounts/<id>/deposit_money", data = "<data>")]
pub fn deposit_money(id: UUID, data: JSON<DepositMoneyData>) {
unimplemented!()
}
#[post(... | WithdrawMoneyData | identifier_name |
accounts.rs | #![allow(unused_variables)]
use domain::Money;
use rocket_contrib::{JSON, UUID};
use uuid::Uuid;
#[derive(Debug, Copy, Clone, Deserialize)]
pub struct OpenAccountData {
pub initial_balance: Money,
}
#[derive(Debug, Clone, Deserialize)]
pub struct DepositMoneyData {
pub transfer_id: Uuid,
pub amount: Mone... |
#[post("/accounts/<id>/close_account")]
pub fn close_account(id: UUID) {
unimplemented!()
}
| {
unimplemented!()
} | identifier_body |
lib.rs | pub fn primefactors(n: isize) -> Vec<isize> {
let mut number = n;
let mut factors = Vec::new();
if number % 2 == 0 {
factors.push(2);
number = number / 2;
}
let mut factor = 3;
let upperlimit = (n as f64).sqrt() as isize + 2;
while factor <= upperlimit {
if number % ... |
factors
}
fn find_root(a: f64, x: f64, epsilon: f64) -> f64 {
let nextx = (a/x + x) / 2.0;
if (x-nextx).abs() < epsilon*x {
nextx
}
else {
find_root(a, nextx, epsilon)
}
}
pub fn sqrt(n: f64) -> f64 {
find_root(n, 2.0, 1.0e-40_f64)
}
#[test]
fn test_sqrt() {
assert!(s... | }
factor += 2;
} | random_line_split |
lib.rs | pub fn primefactors(n: isize) -> Vec<isize> {
let mut number = n;
let mut factors = Vec::new();
if number % 2 == 0 {
factors.push(2);
number = number / 2;
}
let mut factor = 3;
let upperlimit = (n as f64).sqrt() as isize + 2;
while factor <= upperlimit {
if number % ... | (n: f64) -> f64 {
find_root(n, 2.0, 1.0e-40_f64)
}
#[test]
fn test_sqrt() {
assert!(sqrt(4.0) == 2.0);
}
#[test]
fn test_primefactors() {
assert!(primefactors(10) == [2, 5]);
assert!(primefactors(13195) == [5,7,13,29]);
}
| sqrt | identifier_name |
lib.rs | pub fn primefactors(n: isize) -> Vec<isize> {
let mut number = n;
let mut factors = Vec::new();
if number % 2 == 0 {
factors.push(2);
number = number / 2;
}
let mut factor = 3;
let upperlimit = (n as f64).sqrt() as isize + 2;
while factor <= upperlimit {
if number % ... | {
assert!(primefactors(10) == [2, 5]);
assert!(primefactors(13195) == [5,7,13,29]);
} | identifier_body | |
lib.rs | pub fn primefactors(n: isize) -> Vec<isize> {
let mut number = n;
let mut factors = Vec::new();
if number % 2 == 0 {
factors.push(2);
number = number / 2;
}
let mut factor = 3;
let upperlimit = (n as f64).sqrt() as isize + 2;
while factor <= upperlimit {
if number % ... |
else {
find_root(a, nextx, epsilon)
}
}
pub fn sqrt(n: f64) -> f64 {
find_root(n, 2.0, 1.0e-40_f64)
}
#[test]
fn test_sqrt() {
assert!(sqrt(4.0) == 2.0);
}
#[test]
fn test_primefactors() {
assert!(primefactors(10) == [2, 5]);
assert!(primefactors(13195) == [5,7,13,29]);
}
| {
nextx
} | conditional_block |
dropck_no_diverge_on_nonregular_3.rs | // Issue 22443: Reject code using non-regular types that would
// otherwise cause dropck to loop infinitely.
//
// This version is just checking that we still sanely handle a trivial
// wrapper around the non-regular type. (It also demonstrates how the
// error messages will report different types depending on which ty... | <T:'static> {
Simple,
Other(FingerTree<T>),
}
fn main() {
let w = //~ ERROR overflow while adding drop-check rules for Option
Some(Wrapper::Simple::<u32>);
//~^ ERROR overflow while adding drop-check rules for Option
//~| ERROR overflow while adding drop-check rules for Wrapper
}
| Wrapper | identifier_name |
dropck_no_diverge_on_nonregular_3.rs | // Issue 22443: Reject code using non-regular types that would
// otherwise cause dropck to loop infinitely.
//
// This version is just checking that we still sanely handle a trivial
// wrapper around the non-regular type. (It also demonstrates how the
// error messages will report different types depending on which ty... | use std::marker::PhantomData;
struct Digit<T> {
elem: T
}
struct Node<T:'static> { m: PhantomData<&'static T> }
enum FingerTree<T:'static> {
Single(T),
// According to the bug report, Digit before Box would infinite loop.
Deep(
Digit<T>,
Box<FingerTree<Node<T>>>,
)
}
enum Wra... | random_line_split | |
main.rs | extern crate clap;
extern crate rusty_post_lib;
use clap::App;
use clap::Arg;
use rusty_post_lib::request::request::{Request, RequestConfig, HttpMethod};
fn | () {
let matches = App::new("rusty-post")
.version("0.1.0")
.about("Make HTTP requests")
.author("Jonathan Rothberg")
.arg(Arg::with_name("request")
.short("X")
.long("request")
.default_value("GET")
.takes_value(true))
... | main | identifier_name |
main.rs | extern crate clap;
extern crate rusty_post_lib;
use clap::App;
use clap::Arg;
use rusty_post_lib::request::request::{Request, RequestConfig, HttpMethod};
fn main() {
let matches = App::new("rusty-post")
.version("0.1.0")
.about("Make HTTP requests")
.author("Jonathan Rothberg")
.ar... |
println!("Headers: {:?}", headers);
let config = RequestConfig::new(method, &headers, data);
let request = Request::new_with_config(u.into(), &config);
let resp = request.request();
println!("{}", resp);
},
None => {}
}
println!("Hello... | Some(m) if m == "" || m == "GET" || m == "get" || m == "Get" => HttpMethod::Get,
Some(m) if m == "POST" || m == "post" || m == "Post" => HttpMethod::Post,
_ => HttpMethod::Get
}; | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.