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 |
|---|---|---|---|---|
kill.rs | #![crate_name = "uu_kill"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Maciej Dziardziel <fiedzia@gmail.com>
*
* For the full copyright and license information, please view the LICENSE file
* that was distributed with this source code.
*/
extern crate getopts;
extern crate libc;
#[macro_us... | pos = 0;
} else {
pos += 1;
print!(" ");
}
}
}
fn list(arg: Option<String>) {
match arg {
Some(ref x) => print_signal(x),
None => print_signals(),
};
}
fn help(opts: &getopts::Options) {
let msg = format!("{0} {1}
Usage:
{0} [options] <... | print!("{}", signal.name);
if idx > 0 && pos > 73 {
println!(""); | random_line_split |
main.rs | #![warn(clippy::all)]
mod channel;
mod guild;
use std::sync::Arc;
use async_trait::async_trait;
use parking_lot::RwLock;
use rendezvous_common::{
anyhow,
futures::prelude::*,
proto::{
bouncer_service_client::BouncerServiceClient, event, ClientType, Event, Header,
MessageCreated, UserRenam... |
}
async fn guild_member_update(&self, _ctx: Context, new: model::event::GuildMemberUpdateEvent) {
let guild_id = new.guild_id;
let new = UserData::from(new);
let mut event = None;
if let Some(m) = self
.guilds
.write()
.get_mut(&guild_id)
... | {
g.members.remove(&user.id);
} | conditional_block |
main.rs | #![warn(clippy::all)]
mod channel;
mod guild;
use std::sync::Arc;
use async_trait::async_trait;
use parking_lot::RwLock;
use rendezvous_common::{
anyhow,
futures::prelude::*,
proto::{
bouncer_service_client::BouncerServiceClient, event, ClientType, Event, Header,
MessageCreated, UserRenam... |
fn register_guild_channel<'a>(&'a self, channel: &GuildChannel) -> bool {
if channel.kind!= ChannelType::Text {
return false;
}
self.channels
.write()
.get_or_insert_with(channel.id, || Channel::Guild(channel.clone()));
true
}
}
#[async_trait]... | {
let mut lock = self.guilds.write();
lock.insert(guild.id, guild.into())
} | identifier_body |
main.rs | #![warn(clippy::all)]
mod channel;
mod guild;
use std::sync::Arc;
use async_trait::async_trait;
use parking_lot::RwLock;
use rendezvous_common::{
anyhow,
futures::prelude::*,
proto::{
bouncer_service_client::BouncerServiceClient, event, ClientType, Event, Header,
MessageCreated, UserRenam... | current_user: RwLock<Option<model::user::CurrentUser>>,
rpc_client: BouncerServiceClient<transport::Channel>,
}
impl Handler {
fn new(rpc_client: BouncerServiceClient<transport::Channel>) -> Self {
Handler {
guilds: Default::default(),
channels: Default::default(),
... |
struct Handler {
guilds: RwLock<GuildMap>,
channels: Arc<RwLock<ChannelList>>, | random_line_split |
main.rs | #![warn(clippy::all)]
mod channel;
mod guild;
use std::sync::Arc;
use async_trait::async_trait;
use parking_lot::RwLock;
use rendezvous_common::{
anyhow,
futures::prelude::*,
proto::{
bouncer_service_client::BouncerServiceClient, event, ClientType, Event, Header,
MessageCreated, UserRenam... | (&self, guild: Guild) -> Option<GuildData> {
let mut lock = self.guilds.write();
lock.insert(guild.id, guild.into())
}
fn register_guild_channel<'a>(&'a self, channel: &GuildChannel) -> bool {
if channel.kind!= ChannelType::Text {
return false;
}
self.channel... | insert_guild | identifier_name |
expr-alt-box.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 test_str() {
let res = match true { true => { ~"happy" },
_ => fail!("not happy at all") };
assert!((res == ~"happy"));
}
pub fn main() { test_box(); test_str(); }
| {
let res = match true { true => { @100 } _ => fail!("wat") };
assert!((*res == 100));
} | identifier_body |
expr-alt-box.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 ... |
// -*- rust -*-
// Tests for match as expressions resulting in boxed types
fn test_box() {
let res = match true { true => { @100 } _ => fail!("wat") };
assert!((*res == 100));
}
fn test_str() {
let res = match true { true => { ~"happy" },
_ => fail!("not happy at all") };
ass... | random_line_split | |
expr-alt-box.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 res = match true { true => { @100 } _ => fail!("wat") };
assert!((*res == 100));
}
fn test_str() {
let res = match true { true => { ~"happy" },
_ => fail!("not happy at all") };
assert!((res == ~"happy"));
}
pub fn main() { test_box(); test_str(); }
| test_box | identifier_name |
task-comm-13.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 | // xfail-fast
#[legacy_modes];
extern mod std;
fn start(c: comm::Chan<int>, start: int, number_of_messages: int) {
let mut i: int = 0;
while i < number_of_messages { c.send(start + i); i += 1; }
}
pub fn main() {
debug!("Check that we don't deadlock.");
let (p, ch) = comm::stream();
task::try(|| ... | // 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.
| random_line_split |
task-comm-13.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 ... | (c: comm::Chan<int>, start: int, number_of_messages: int) {
let mut i: int = 0;
while i < number_of_messages { c.send(start + i); i += 1; }
}
pub fn main() {
debug!("Check that we don't deadlock.");
let (p, ch) = comm::stream();
task::try(|| start(ch, 0, 10) );
debug!("Joined task");
}
| start | identifier_name |
task-comm-13.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 ... | {
debug!("Check that we don't deadlock.");
let (p, ch) = comm::stream();
task::try(|| start(ch, 0, 10) );
debug!("Joined task");
} | identifier_body | |
issue-23825.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.
// |
// run-pass
trait Stringify {
fn to_string(&self) -> String;
}
impl Stringify for u32 {
fn to_string(&self) -> String { format!("u32: {}", *self) }
}
impl Stringify for f32 {
fn to_string(&self) -> String { format!("f32: {}", *self) }
}
fn print<T: Stringify>(x: T) -> String {
x.to_string()
}
fn ma... | // 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. | random_line_split |
issue-23825.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 ... |
}
fn print<T: Stringify>(x: T) -> String {
x.to_string()
}
fn main() {
assert_eq!(&print(5), "u32: 5");
assert_eq!(&print(5.0), "f32: 5");
}
| { format!("f32: {}", *self) } | identifier_body |
issue-23825.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 ... | <T: Stringify>(x: T) -> String {
x.to_string()
}
fn main() {
assert_eq!(&print(5), "u32: 5");
assert_eq!(&print(5.0), "f32: 5");
}
| print | identifier_name |
size_of.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 script::dom::characterdata::CharacterData;
use script::dom::element::Element;
use script::dom::eventtarget::Ev... | fn $testname() {
let new = size_of::<$t>();
let old = $known_size;
if new < old {
panic!("Your changes have decreased the stack size of commonly used DOM struct {} from {} to {}. \
Good work! Please update the size in tests/unit/script/... | macro_rules! sizeof_checker (
($testname: ident, $t:ty, $known_size:expr) => (
#[test] | random_line_split |
cellrenderertoggle.rs | // (at your option) any later version.
//
// rgtk is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a ... | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or | random_line_split | |
cellrenderertoggle.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... |
pub fn get_active(&mut self) -> bool {
unsafe {
ffi::to_bool(ffi::gtk_cell_renderer_toggle_get_active(
self.pointer as *mut ffi::C_GtkCellRendererToggle))
}
}
pub fn set_active(&mut self, active: bool) -> () {
unsafe {
ffi::gtk_cell_renderer... | {
unsafe {
ffi::gtk_cell_renderer_toggle_set_radio(
self.pointer as *mut ffi::C_GtkCellRendererToggle, ffi::to_gboolean(radio));
}
} | identifier_body |
cellrenderertoggle.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | (&mut self) -> bool {
unsafe {
ffi::to_bool(ffi::gtk_cell_renderer_toggle_get_active(
self.pointer as *mut ffi::C_GtkCellRendererToggle))
}
}
pub fn set_active(&mut self, active: bool) -> () {
unsafe {
ffi::gtk_cell_renderer_toggle_set_active(
... | get_active | identifier_name |
pool.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::mem;
use std::sync::Arc;
use curl::multi::Multi;
use parking_lot::Mutex... |
}
| {
let mut heap = BinaryHeap::from(vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
truncate(&mut heap, 5);
assert_eq!(heap.into_sorted_vec(), vec![5, 6, 7, 8, 9]);
} | identifier_body |
pool.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::mem;
use std::sync::Arc;
use curl::multi::Multi;
use parking_lot::Mutex... | (mut self) {
self.valid = false;
}
}
impl Drop for PoolMulti {
fn drop(&mut self) {
if self.valid {
self.pool.push(self.entry.take().unwrap());
}
}
}
/// Shared state between a `Pool` and its associated `PoolMulti`s.
struct PoolInner {
heap: Mutex<BinaryHeap<PoolEnt... | discard | identifier_name |
pool.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::mem;
use std::sync::Arc;
use curl::multi::Multi;
use parking_lot::Mutex... |
}
}
/// Shared state between a `Pool` and its associated `PoolMulti`s.
struct PoolInner {
heap: Mutex<BinaryHeap<PoolEntry>>,
}
impl PoolInner {
fn new() -> Self {
Self {
heap: Mutex::new(BinaryHeap::new()),
}
}
/// Pop an existing `Multi` or create a new one if none ... | {
self.pool.push(self.entry.take().unwrap());
} | conditional_block |
pool.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::mem;
use std::sync::Arc;
use curl::multi::Multi;
use parking_lot::Mutex... |
{
// Get a handle for the first time.
let multi = pool.multi();
assert_eq!(multi.entry.as_ref().unwrap().priority, 0);
}
{
// Check that we reused the existing handle.
let multi = pool.multi();
assert_eq!(multi.entry.as_re... | use super::*;
#[test]
fn test_pool() {
let pool = Pool::new(); | random_line_split |
borrowck-loan-vec-content.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() {
}
| {
let mut v = ~[1, 2, 3];
do takes_const_elt(&const v[0]) {
v[1] = 4;
}
} | identifier_body |
borrowck-loan-vec-content.rs | // 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.
// Here we check th... | // 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.
// | random_line_split | |
borrowck-loan-vec-content.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 v = ~[1, 2, 3];
do takes_imm_elt(&v[0]) {
v[1] = 4; //~ ERROR cannot assign
}
}
fn takes_const_elt(_v: &const int, f: &fn()) {
f();
}
fn has_mut_vec_and_tries_to_change_it() {
let mut v = ~[1, 2, 3];
do takes_const_elt(&const v[0]) {
v[1] = 4;
}
}
fn main() {
... | has_mut_vec_but_tries_to_change_it | identifier_name |
canvas_ext.rs | use crate::cache;
use crate::view::ScreenVector;
use euclid::default::Point2D;
use euclid::vec2;
use vitral::Canvas;
use vitral::{color, Align};
use world::Icon;
/// Magog-specific extensions to Canvas API.
pub trait CanvasExt {
fn draw_entity(&mut self, pos: Point2D<i32>, icon: Icon, count: u32);
fn draw_ite... |
}
}
| {
self.draw_outline_text(
&*cache::tiny_font(),
pos - vec2(9, 9),
Align::Left,
color::SILVER,
color::GRAY2,
&format!("{}", count),
);
} | conditional_block |
canvas_ext.rs | use crate::cache;
use crate::view::ScreenVector;
use euclid::default::Point2D;
use euclid::vec2;
use vitral::Canvas;
use vitral::{color, Align};
use world::Icon;
/// Magog-specific extensions to Canvas API.
pub trait CanvasExt {
fn draw_entity(&mut self, pos: Point2D<i32>, icon: Icon, count: u32);
fn draw_ite... | if count > 1 {
self.draw_outline_text(
&*cache::tiny_font(),
pos - vec2(9, 9),
Align::Left,
color::SILVER,
color::GRAY2,
&format!("{}", count),
);
}
}
} | splat.color,
splat.back_color,
);
}
| random_line_split |
canvas_ext.rs | use crate::cache;
use crate::view::ScreenVector;
use euclid::default::Point2D;
use euclid::vec2;
use vitral::Canvas;
use vitral::{color, Align};
use world::Icon;
/// Magog-specific extensions to Canvas API.
pub trait CanvasExt {
fn draw_entity(&mut self, pos: Point2D<i32>, icon: Icon, count: u32);
fn draw_ite... | (&mut self, pos: Point2D<i32>, icon: Icon, count: u32) {
let vec = ScreenVector::from_untyped(pos.to_vector());
for splat in &cache::entity(icon)[0] {
self.draw_image_2color(
&splat.image,
(vec - splat.offset).to_point().to_untyped(),
splat.col... | draw_entity | identifier_name |
canvas_ext.rs | use crate::cache;
use crate::view::ScreenVector;
use euclid::default::Point2D;
use euclid::vec2;
use vitral::Canvas;
use vitral::{color, Align};
use world::Icon;
/// Magog-specific extensions to Canvas API.
pub trait CanvasExt {
fn draw_entity(&mut self, pos: Point2D<i32>, icon: Icon, count: u32);
fn draw_ite... | }
}
}
| {
let vec = ScreenVector::from_untyped(pos.to_vector());
for splat in &cache::entity(icon)[0] {
self.draw_image_2color(
&splat.image,
(vec - splat.offset).to_point().to_untyped(),
splat.color,
splat.back_color,
);
... | identifier_body |
lib.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/. */
#![feature(box_syntax)]
#![feature(box_patterns)]
#![feature(concat_idents)]
#![feature(core_intrinsics)]
#![featu... | #![plugin(heapsize_plugin)]
#![plugin(plugins)]
#![plugin(serde_macros)]
#![deny(unsafe_code)]
#![recursion_limit = "500"] // For match_ignore_ascii_case in PropertyDeclaration::parse
extern crate app_units;
#[allow(unused_extern_crates)]
#[macro_use]
extern crate bitflags;
extern crate core;
#[macro_use]
extern cr... | random_line_split | |
network.rs | use std::io;
use std::io::Cursor;
use std::convert::From;
use std::str::FromStr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use regex::Regex;
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use error::{SocketError, Result};
use util::slice2str;
macro_rules! slice2sized {
($bytes:expr, $... |
fn put_u16(&mut self, num: u16) -> io::Result<()> {
self.write_u16::<NetworkEndian>(num)
}
fn put_i32(&mut self, num: i32) -> io::Result<()> {
self.write_i32::<NetworkEndian>(num)
}
}
impl NetworkWriteBytes for Vec<u8> {}
pub trait NetworkReadBytes: ReadBytesExt {
fn get_u8(&mut... | {
self.write_u8(num)
} | identifier_body |
network.rs | use std::io;
use std::io::Cursor;
use std::convert::From;
use std::str::FromStr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use regex::Regex;
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use error::{SocketError, Result};
use util::slice2str;
macro_rules! slice2sized {
($bytes:expr, $... | (&mut self, num: u16) -> io::Result<()> {
self.write_u16::<NetworkEndian>(num)
}
fn put_i32(&mut self, num: i32) -> io::Result<()> {
self.write_i32::<NetworkEndian>(num)
}
}
impl NetworkWriteBytes for Vec<u8> {}
pub trait NetworkReadBytes: ReadBytesExt {
fn get_u8(&mut self) -> io::Re... | put_u16 | identifier_name |
network.rs | use std::io;
use std::io::Cursor;
use std::convert::From;
use std::str::FromStr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use regex::Regex;
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use error::{SocketError, Result};
use util::slice2str;
macro_rules! slice2sized {
($bytes:expr, $... | .split(|c| *c == b'.')
.all(|s| {
let s = slice2str(s).unwrap_or("");
!s.is_empty() &&!s.starts_with('-') &&!s.ends_with('-') && RE.is_match(s)
})
}
pub fn slice2ip4(data: &[u8]) -> Option<String> {
if data.len() >= 4 {
Some(format!("{}", Ipv4Addr::from(slice2si... | random_line_split | |
network.rs | use std::io;
use std::io::Cursor;
use std::convert::From;
use std::str::FromStr;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr};
use regex::Regex;
use byteorder::{NetworkEndian, ReadBytesExt, WriteBytesExt};
use error::{SocketError, Result};
use util::slice2str;
macro_rules! slice2sized {
($bytes:expr, $... | else {
None
}
}
pub fn pair2addr4(ip: &str, port: u16) -> Option<SocketAddr> {
Ipv4Addr::from_str(ip).map(|ip| SocketAddr::new(IpAddr::V4(ip), port)).ok()
}
pub fn pair2addr6(ip: &str, port: u16) -> Option<SocketAddr> {
Ipv6Addr::from_str(ip).map(|ip| SocketAddr::new(IpAddr::V6(ip), port)).ok()
}... | {
Some(format!("{}", Ipv6Addr::from(slice2sized!(data, 16))))
} | conditional_block |
poll.rs | use error::MioResult;
use io::IoHandle;
use os;
use os::token::Token;
use os::event;
pub struct Poll {
selector: os::Selector,
events: os::Events
}
impl Poll {
pub fn new() -> MioResult<Poll> {
Ok(Poll {
selector: try!(os::Selector::new()),
events: os::Events::new()
... | pub fn poll(&mut self, timeout_ms: usize) -> MioResult<usize> {
try!(self.selector.select(&mut self.events, timeout_ms));
Ok(self.events.len())
}
pub fn event(&self, idx: usize) -> event::IoEvent {
self.events.get(idx)
}
pub fn iter(&self) -> EventsIterator {
Events... | random_line_split | |
poll.rs | use error::MioResult;
use io::IoHandle;
use os;
use os::token::Token;
use os::event;
pub struct Poll {
selector: os::Selector,
events: os::Events
}
impl Poll {
pub fn new() -> MioResult<Poll> {
Ok(Poll {
selector: try!(os::Selector::new()),
events: os::Events::new()
... |
}
}
| {
self.index += 1;
Some(self.events.get(self.index - 1))
} | conditional_block |
poll.rs | use error::MioResult;
use io::IoHandle;
use os;
use os::token::Token;
use os::event;
pub struct Poll {
selector: os::Selector,
events: os::Events
}
impl Poll {
pub fn new() -> MioResult<Poll> {
Ok(Poll {
selector: try!(os::Selector::new()),
events: os::Events::new()
... | (&mut self, timeout_ms: usize) -> MioResult<usize> {
try!(self.selector.select(&mut self.events, timeout_ms));
Ok(self.events.len())
}
pub fn event(&self, idx: usize) -> event::IoEvent {
self.events.get(idx)
}
pub fn iter(&self) -> EventsIterator {
EventsIterator { even... | poll | identifier_name |
poll.rs | use error::MioResult;
use io::IoHandle;
use os;
use os::token::Token;
use os::event;
pub struct Poll {
selector: os::Selector,
events: os::Events
}
impl Poll {
pub fn new() -> MioResult<Poll> {
Ok(Poll {
selector: try!(os::Selector::new()),
events: os::Events::new()
... |
pub fn poll(&mut self, timeout_ms: usize) -> MioResult<usize> {
try!(self.selector.select(&mut self.events, timeout_ms));
Ok(self.events.len())
}
pub fn event(&self, idx: usize) -> event::IoEvent {
self.events.get(idx)
}
pub fn iter(&self) -> EventsIterator {
Even... | {
debug!("deregistering IO with poller");
// Deregister interests for this socket
try!(self.selector.deregister(io.desc()));
Ok(())
} | identifier_body |
chrome_trace.rs | // Copyright 2018 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 w... |
pub fn deserialize<R>(input: R) -> Result<Vec<Sample>, Error>
where R: Read
{
let entries : ChromeTraceArrayEntries = serde_json::from_reader(input).map_err(Error::Json)?;
Vec::try_from(entries)
}
| {
let entries = ChromeTraceArrayEntries::deserialize(samples).map_err(Error::Json)?;
Vec::try_from(entries)
} | identifier_body |
chrome_trace.rs | // Copyright 2018 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 w... | result.push(sample_to_entry(&sample, false));
}
}
}
ChromeTraceArrayEntries::Array(result)
}
}
// temporary while TryFrom is still nightly.
pub trait XiTryFrom<T>: Sized {
type Error;
fn try_from(value: T) -> Result<Self, Self::Error>;
}
fn t... | random_line_split | |
chrome_trace.rs | // Copyright 2018 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 w... | (sample: &Sample, begin: bool) -> &'static str {
match sample.sample_type {
SampleType::Instant => "i",
SampleType::Duration => if begin { "B" } else { "E" },
}
}
fn sample_to_entry(sample: &Sample, begin: bool) -> ChromeTraceArrayEntry {
ChromeTraceArrayEntry {
name: sample.name.cl... | event_type | identifier_name |
lib.rs | /*
* The MIT License (MIT)
*
* Copyright (c) 2015 Mattis Marjak (mattis.marjak@gmail.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limit... | extern crate time;
mod timer;
mod storage;
#[macro_use]
mod macros;
#[cfg(test)]
mod test;
pub use timer::{Timer, TimerAction};
pub use storage::{TimerStorage, TimerEvent}; | trivial_casts, trivial_numeric_casts, unsafe_code,
unstable_features, unused_import_braces, unused_qualifications)]
#[macro_use]
extern crate log; | random_line_split |
p501.rs | // use std::collections::HashMap;
use common::iter;
use std::thread;
use std::sync::Arc;
use std::sync::mpsc;
use tempfile::NamedTempFileOptions;
use std::io::Write;
use std::io::BufReader;
use tempfile::NamedTempFile;
use std::io::BufRead;
fn prim_vec(max: &u64) -> NamedTempFile {
let mut named_temp_file = NamedT... | }
named_temp_file
}
pub fn exe(max: u64) -> u64 {
let tmp_file = prim_vec(&max);
//;
let primes = BufReader::new(tmp_file.reopen().unwrap())
.lines()
.map(|l| &l.unwrap().parse::<u64>().unwrap());
println!("素数生成完了");
let count_1: u64 = (&primes.cloned()).take_while(|&a| a... | for i in iter::prime_iter().take_while(|i| i < &prime_max) {
writeln!(&mut named_temp_file, "{}", i);
| random_line_split |
p501.rs | // use std::collections::HashMap;
use common::iter;
use std::thread;
use std::sync::Arc;
use std::sync::mpsc;
use tempfile::NamedTempFileOptions;
use std::io::Write;
use std::io::BufReader;
use tempfile::NamedTempFile;
use std::io::BufRead;
fn prim_vec(max: &u64) -> NamedTempFile {
let mut named_temp_file = NamedT... | (max: u64) -> u64 {
let tmp_file = prim_vec(&max);
//;
let primes = BufReader::new(tmp_file.reopen().unwrap())
.lines()
.map(|l| &l.unwrap().parse::<u64>().unwrap());
println!("素数生成完了");
let count_1: u64 = (&primes.cloned()).take_while(|&a| a * a * a * a * a * a * a < max)
// ... | exe | identifier_name |
p501.rs | // use std::collections::HashMap;
use common::iter;
use std::thread;
use std::sync::Arc;
use std::sync::mpsc;
use tempfile::NamedTempFileOptions;
use std::io::Write;
use std::io::BufReader;
use tempfile::NamedTempFile;
use std::io::BufRead;
fn prim_vec(max: &u64) -> NamedTempFile {
let mut named_temp_file = NamedT... | fn exe_100_bench(b: &mut Bencher) {
b.iter(|| super::exe(100));
}
#[test]
fn exe_1_000_test() {
assert_eq!(super::exe(1_000), 180);
}
#[bench]
fn exe_1_000_bench(b: &mut Bencher) {
b.iter(|| super::exe(1_000));
}
// test prob501_600::prob501_510::p501::tests::ex... | (super::exe(100), 10);
}
#[bench]
| identifier_body |
mem_init.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... |
/// Helper function to initialize memory.
/// Copies `.data` sections in to RAM and initializes `.bss` sections to zero.
#[inline(always)]
pub fn init_data() {
unsafe {
let mut load_addr: *const u32 = &_data_load;
let mut mem_addr: *mut u32 = &mut _data;
while mem_addr < &mut _edata as *mut u32 {
... | {
set_stack_limit( unsafe { (&_eglobals as *const u32) } as u32);
} | identifier_body |
mem_init.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | () {
unsafe {
let mut load_addr: *const u32 = &_data_load;
let mut mem_addr: *mut u32 = &mut _data;
while mem_addr < &mut _edata as *mut u32 {
*mem_addr = *load_addr;
mem_addr = ((mem_addr as u32) + 4) as *mut u32;
load_addr = ((load_addr as u32) + 4) as *const u32;
}
mem_addr =... | init_data | identifier_name |
mem_init.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// 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.o... | set_stack_limit( unsafe { (&_eglobals as *const u32) } as u32);
}
/// Helper function to initialize memory.
/// Copies `.data` sections in to RAM and initializes `.bss` sections to zero.
#[inline(always)]
pub fn init_data() {
unsafe {
let mut load_addr: *const u32 = &_data_load;
let mut mem_addr: *mut u32 ... |
/// Helper function to initialise the stack limit.
#[inline(always)]
pub fn init_stack() { | random_line_split |
lib.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/. */
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(custom_derive)]
#![cfg_attr(fea... | {
let a: &T = &**a;
let b: &T = &**b;
(a as *const T) == (b as *const T)
} | identifier_body | |
lib.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/. */
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(custom_derive)]
#![cfg_attr(fea... | #[cfg(feature = "non-geckolib")]
pub mod non_geckolib;
pub mod opts;
pub mod persistent_list;
pub mod prefs;
pub mod print_tree;
pub mod range;
pub mod resource_files;
pub mod str;
pub mod thread;
pub mod thread_state;
pub mod threadpool;
pub mod tid;
pub mod time;
pub mod vec;
pub mod workqueue;
pub fn breakpoint() {... | pub mod logical_geometry;
#[macro_use] pub mod mem; | random_line_split |
lib.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/. */
#![feature(alloc)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(custom_derive)]
#![cfg_attr(fea... | () {
unsafe { ::std::intrinsics::breakpoint() };
}
// Workaround for lack of `ptr_eq` on Arcs...
#[inline]
pub fn arc_ptr_eq<T:'static + Send + Sync>(a: &Arc<T>, b: &Arc<T>) -> bool {
let a: &T = &**a;
let b: &T = &**b;
(a as *const T) == (b as *const T)
}
| breakpoint | identifier_name |
cloned.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::clone::Clone;
// #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Option<T> {
// /// No value
// #[stable(feature = "rust1", since = "... |
}
type T = i32; // T: Clone
#[test]
fn cloned_test1() {
let a: A<T> = A { value: 68 };
let x: Option<&A<T>> = Some::<&A<T>>(&a);
let cloned: Option<A<T>> = x.cloned();
assert_eq!(x.unwrap().value, 68);
assert_eq!(cloned.unwrap().value, 68);
}
}
| {
A { value: self.value }
} | identifier_body |
cloned.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::clone::Clone;
// #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Option<T> {
// /// No value
// #[stable(feature = "rust1", since = "... | fn clone(&self) -> Self
{
A { value: self.value }
}
}
type T = i32; // T: Clone
#[test]
fn cloned_test1() {
let a: A<T> = A { value: 68 };
let x: Option<&A<T>> = Some::<&A<T>>(&a);
let cloned: Option<A<T>> = x.cloned();
assert_eq!(x.unwrap().value, 68);
assert_eq!(cloned.unwrap().value,... | struct A<T> {
value: T
}
impl Clone for A<T> { | random_line_split |
cloned.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::clone::Clone;
// #[derive(Clone, Copy, PartialEq, PartialOrd, Eq, Ord, Debug, Hash)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Option<T> {
// /// No value
// #[stable(feature = "rust1", since = "... | () {
let a: A<T> = A { value: 68 };
let x: Option<&A<T>> = Some::<&A<T>>(&a);
let cloned: Option<A<T>> = x.cloned();
assert_eq!(x.unwrap().value, 68);
assert_eq!(cloned.unwrap().value, 68);
}
}
| cloned_test1 | identifier_name |
executer.rs | use std::error;
use std::process;
use crate::command::error::CommandError;
use crate::config;
use crate::output;
use super::super::Executer as ParamsExecuter;
use super::{Arguments, Program};
pub struct Executer<'c> {
config: &'c config::command::ParamsConfig,
}
impl<'c> Executer<'c> {
pub fn from_config(co... |
}
| {
&self.config
} | identifier_body |
executer.rs | use std::error;
use std::process;
use crate::command::error::CommandError;
use crate::config;
use crate::output;
use super::super::Executer as ParamsExecuter;
use super::{Arguments, Program};
pub struct Executer<'c> {
config: &'c config::command::ParamsConfig,
}
impl<'c> Executer<'c> {
pub fn from_config(co... | }
} | random_line_split | |
executer.rs | use std::error;
use std::process;
use crate::command::error::CommandError;
use crate::config;
use crate::output;
use super::super::Executer as ParamsExecuter;
use super::{Arguments, Program};
pub struct Executer<'c> {
config: &'c config::command::ParamsConfig,
}
impl<'c> Executer<'c> {
pub fn from_config(co... | (
&self,
program: &'c Program<'c>,
args: &'c Arguments<'c>,
) -> Result<(), Box<dyn error::Error>> {
trace!("command::params::exec::Executer::run");
info!("exec: {} {}", program, args.join(" "));
let params = self.params().await?;
let mut cmd = process::Comma... | run | identifier_name |
executer.rs | use std::error;
use std::process;
use crate::command::error::CommandError;
use crate::config;
use crate::output;
use super::super::Executer as ParamsExecuter;
use super::{Arguments, Program};
pub struct Executer<'c> {
config: &'c config::command::ParamsConfig,
}
impl<'c> Executer<'c> {
pub fn from_config(co... | else {
output::PrintLine::error(&format!(
"Command exit with status code: {}",
output.code().unwrap_or(0)
));
Err(Box::new(CommandError::Unknown))
}
}
}
impl<'c> ParamsExecuter for Executer<'c> {
fn config(&self) -> &config::command::... | {
Ok(())
} | conditional_block |
task-comm-11.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 ... |
pub fn main() {
let (p, ch) = comm::stream();
let _child = task::spawn(proc() start(&ch) );
let _c = p.recv();
}
| {
let (_p, ch) = comm::stream();
c.send(ch);
} | identifier_body |
task-comm-11.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. | // 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.
// xfail-fast
extern mod extra;
use std::comm;
use std::task;
fn start(c: &comm::Chan... | //
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | random_line_split |
task-comm-11.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 (p, ch) = comm::stream();
let _child = task::spawn(proc() start(&ch) );
let _c = p.recv();
}
| main | identifier_name |
scope_table_builder.rs | //! Build the scope table and make sure all variables/symbols can be resolved |
use driver::interner::Ident;
use driver::session;
use driver::symbol_table::SymbolTable;
use front::ast::*;
use front::ast::visit::*;
struct ScopeTableBuilder<'a> {
current_scope: Option<NodeId>,
current_symbol: Option<Ident>,
sytbl: &'a SymbolTable
}
impl<'a> ScopeTableBuilder<'a> {
fn new(sytbl: &... | random_line_split | |
scope_table_builder.rs | //! Build the scope table and make sure all variables/symbols can be resolved
use driver::interner::Ident;
use driver::session;
use driver::symbol_table::SymbolTable;
use front::ast::*;
use front::ast::visit::*;
struct ScopeTableBuilder<'a> {
current_scope: Option<NodeId>,
current_symbol: Option<Ident>,
... |
}
// Continue walking the expression
walk_expression(self, expr)
}
}
pub fn run(program: &[Node<Symbol>]) {
let symbol_table = &session().symbol_table;
let mut visitor = ScopeTableBuilder::new(symbol_table);
walk_program(&mut visitor, program);
session().abort_if_errors()... | {} | conditional_block |
scope_table_builder.rs | //! Build the scope table and make sure all variables/symbols can be resolved
use driver::interner::Ident;
use driver::session;
use driver::symbol_table::SymbolTable;
use front::ast::*;
use front::ast::visit::*;
struct ScopeTableBuilder<'a> {
current_scope: Option<NodeId>,
current_symbol: Option<Ident>,
... | (&self, expr: &Node<Expression>) {
// Get function name
let name = if let Expression::Variable { ref name } = **expr {
name
} else {
fatal_at!("cannot call non-function"; expr);
return
};
// Look up the symbol in the symbol table
let s... | resolve_call | identifier_name |
scope_table_builder.rs | //! Build the scope table and make sure all variables/symbols can be resolved
use driver::interner::Ident;
use driver::session;
use driver::symbol_table::SymbolTable;
use front::ast::*;
use front::ast::visit::*;
struct ScopeTableBuilder<'a> {
current_scope: Option<NodeId>,
current_symbol: Option<Ident>,
... |
fn visit_expression(&mut self, expr: &'v Node<Expression>) {
match **expr {
Expression::Call { ref func,.. } => {
self.resolve_call(func);
return // Don't visit sub-expressions
},
Expression::Variable { ref name } => {
se... | {
if let Statement::Declaration { ref binding, .. } = **stmt {
self.resolve_declaration(binding);
}
walk_statement(self, stmt)
} | identifier_body |
issue-11709.rs | // run-pass
#![allow(dead_code)]
// ignore-pretty issue #37199
// Don't panic on blocks without results
// There are several tests in this run-pass that raised
// when this bug was opened. The cases where the compiler
// panics before the fix have a comment.
struct S {x:()}
fn test(slot: &mut Option<Box<dyn FnMut() ... | () {
// {} would break
let _r = {};
let mut slot = None;
// `{ test(...); }` would break
let _s : S = S{ x: { test(&mut slot); } };
let _b = not(true);
}
| main | identifier_name |
issue-11709.rs | // run-pass
#![allow(dead_code)]
// ignore-pretty issue #37199
// Don't panic on blocks without results
// There are several tests in this run-pass that raised
// when this bug was opened. The cases where the compiler
// panics before the fix have a comment.
struct S {x:()}
fn test(slot: &mut Option<Box<dyn FnMut() ... | else {
// `panic!(...)` would break
panic!("Break the compiler");
}
}
pub fn main() {
// {} would break
let _r = {};
let mut slot = None;
// `{ test(...); }` would break
let _s : S = S{ x: { test(&mut slot); } };
let _b = not(true);
}
| {
!b
} | conditional_block |
issue-11709.rs | // run-pass
#![allow(dead_code)]
// ignore-pretty issue #37199
// Don't panic on blocks without results
// There are several tests in this run-pass that raised
// when this bug was opened. The cases where the compiler
// panics before the fix have a comment.
struct S {x:()}
fn test(slot: &mut Option<Box<dyn FnMut() ... |
let _b = not(true);
} | // `{ test(...); }` would break
let _s : S = S{ x: { test(&mut slot); } }; | random_line_split |
empty-enum.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
pub type EmptyConstified = u32;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum | {
__bindgen_cannot_repr_c_on_empty_enum = 0,
}
pub mod EmptyModule {
pub type Type = u32;
}
#[repr(i8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum EmptyClassRustified {
__bindgen_cannot_repr_c_on_empty_enum = 0,
}
pub type EmptyClassConstified = i8;
pub mod EmptyClassModule {
pub type ... | EmptyRustified | identifier_name |
empty-enum.rs | /* automatically generated by rust-bindgen */
#![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
pub type EmptyConstified = u32;
#[repr(u32)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum EmptyRustified {
__bindgen_cannot_repr_c_on_empty_enum = 0, | pub mod EmptyModule {
pub type Type = u32;
}
#[repr(i8)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum EmptyClassRustified {
__bindgen_cannot_repr_c_on_empty_enum = 0,
}
pub type EmptyClassConstified = i8;
pub mod EmptyClassModule {
pub type Type = i8;
}
#[repr(i8)]
#[derive(Debug, Copy, Clone... | } | random_line_split |
packed-struct-transmute.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 ... | struct Foo {
bar: u8,
baz: uint
}
#[deriving(Show)]
struct Oof {
rab: u8,
zab: uint
}
fn main() {
let foo = Foo { bar: 1, baz: 10 };
unsafe {
let oof: Oof = mem::transmute(foo);
println!("{}", oof);
}
} | random_line_split | |
packed-struct-transmute.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 foo = Foo { bar: 1, baz: 10 };
unsafe {
let oof: Oof = mem::transmute(foo);
println!("{}", oof);
}
}
| main | identifier_name |
packed-struct-transmute.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 foo = Foo { bar: 1, baz: 10 };
unsafe {
let oof: Oof = mem::transmute(foo);
println!("{}", oof);
}
} | identifier_body | |
admin.rs | extern crate bytes;
extern crate futures;
extern crate rustygear;
extern crate rustygeard;
use std::sync::{Arc, Mutex};
use std::collections::BTreeMap;
use bytes::Bytes;
use rustygear::constants::*;
use rustygear::job::Job;
use rustygeard::admin::{admin_command_status, admin_command_workers};
use rustygeard::queues... | assert_eq!(expected, response);
} | wbci.insert(11, worker);
}
let packet = admin_command_workers(workers_by_conn_id);
let response = String::from_utf8(packet.data.to_vec()).unwrap();
let expected = String::from("10 127.0.0.1:37337 hacker1 : hack\n11 127.0.0.1:33333 - :\n.\n"); | random_line_split |
admin.rs | extern crate bytes;
extern crate futures;
extern crate rustygear;
extern crate rustygeard;
use std::sync::{Arc, Mutex};
use std::collections::BTreeMap;
use bytes::Bytes;
use rustygear::constants::*;
use rustygear::job::Job;
use rustygeard::admin::{admin_command_status, admin_command_workers};
use rustygeard::queues... |
#[test]
fn admin_command_workers_with2() {
let workers_by_conn_id: WorkersByConnId = Arc::new(Mutex::new(BTreeMap::new()));
{
let mut wbci = workers_by_conn_id.lock().unwrap();
let worker = Arc::new(Mutex::new(Worker::new("127.0.0.1:37337".parse().unwrap(), Bytes::from("hacker1"))));
{... | {
let workers_by_conn_id = Arc::new(Mutex::new(BTreeMap::new()));
let packet = admin_command_workers(workers_by_conn_id);
assert_eq!(b".\n", &packet.data[..]);
} | identifier_body |
admin.rs | extern crate bytes;
extern crate futures;
extern crate rustygear;
extern crate rustygeard;
use std::sync::{Arc, Mutex};
use std::collections::BTreeMap;
use bytes::Bytes;
use rustygear::constants::*;
use rustygear::job::Job;
use rustygeard::admin::{admin_command_status, admin_command_workers};
use rustygeard::queues... | () {
let workers_by_conn_id: WorkersByConnId = Arc::new(Mutex::new(BTreeMap::new()));
{
let mut wbci = workers_by_conn_id.lock().unwrap();
let worker = Arc::new(Mutex::new(Worker::new("127.0.0.1:37337".parse().unwrap(), Bytes::from("hacker1"))));
{
let mut worker = worker.loc... | admin_command_workers_with2 | identifier_name |
stdio.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 ... | () -> StdReader {
src(libc::STDIN_FILENO, true, |src| StdReader { inner: src })
}
/// Creates a line-buffered handle to the stdout of the current process.
///
/// Note that this is a fairly expensive operation in that at least one memory
/// allocation is performed. Additionally, this must be called from a runtime... | stdin_raw | identifier_name |
stdio.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 write(&mut self, buf: &[u8]) -> IoResult<()> {
// As with stdin on windows, stdout often can't handle writes of large
// sizes. For an example, see #14940. For this reason, chunk the output
// buffer on windows, but on unix we can just write the whole buffer all
// at once.
... | }
impl Writer for StdWriter { | random_line_split |
lib.rs | //! SeaHash: A blazingly fast, portable hash function with proven statistical guarantees.
//!
//! SeaHash is a hash function with performance better than (around 3-20% improvement) xxHash and
//! MetroHash. Furthermore, SeaHash has mathematically provable statistical guarantees.
//!
//! SeaHash is a portable hash funct... | //!
//! If the diffusion function (f) was cryptographically secure, it would pass cryptoanalysis
//! trivially. This might seem irrelevant, as it clearly isn't cryptographically secure, but it
//! tells us something about the inner semantics. In particular, any diffusion function with
//! sufficient statistical quality... | //! The advantage of having four completely segregated (note that there is no mix round, so they're
//! entirely independent) states is that fast parallelism is possible. For example, if I were to
//! hash 1 TB, I can spawn up four threads which can run independently without _any_
//! intercommunication or synchronizat... | random_line_split |
event.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... | (&self) -> bool {
self.stop_propagation.get()
}
#[inline]
pub fn stop_immediate(&self) -> bool {
self.stop_immediate.get()
}
#[inline]
pub fn bubbles(&self) -> bool {
self.bubbles.get()
}
#[inline]
pub fn dispatching(&self) -> bool {
self.dispatchin... | stop_propagation | identifier_name |
event.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... |
#[inline]
pub fn type_id<'a>(&'a self) -> &'a EventTypeId {
&self.type_id
}
#[inline]
pub fn clear_current_target(&self) {
self.current_target.clear();
}
#[inline]
pub fn set_current_target(&self, val: JSRef<EventTarget>) {
self.current_target.assign(Some(val)... | {
let bubbles = if init.bubbles { EventBubbles::Bubbles } else { EventBubbles::DoesNotBubble };
let cancelable = if init.cancelable { EventCancelable::Cancelable } else { EventCancelable::NotCancelable };
Ok(Event::new(global, type_, bubbles, cancelable))
} | identifier_body |
event.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... | }
fn InitEvent(self,
type_: DOMString,
bubbles: bool,
cancelable: bool) {
if self.dispatching.get() {
return;
}
self.initialized.set(true);
self.stop_propagation.set(false);
self.stop_immediate.set(false);
... | random_line_split | |
event.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::cell::DOMRefCell;
use dom::bindings::codegen::Bindings::EventBinding;
use dom::bindings::codege... | else { EventBubbles::DoesNotBubble };
let cancelable = if init.cancelable { EventCancelable::Cancelable } else { EventCancelable::NotCancelable };
Ok(Event::new(global, type_, bubbles, cancelable))
}
#[inline]
pub fn type_id<'a>(&'a self) -> &'a EventTypeId {
&self.type_id
}
... | { EventBubbles::Bubbles } | conditional_block |
issue-8860.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... |
}
fn f(ref _s: S) {}
struct T { i: int }
impl Drop for T {
fn drop(&mut self) {
unsafe {
DROP_T += 1;
DROP += 1;
}
}
}
fn g(ref _t: T) {}
fn main() {
let s = S;
f(s);
unsafe {
assert_eq!(1, DROP);
assert_eq!(1, DROP_S);
}
let t = T {... | {
unsafe {
DROP_S += 1;
DROP += 1;
}
} | identifier_body |
issue-8860.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... | }
ret
}
struct S;
impl Drop for S {
fn drop(&mut self) {
unsafe {
DROP_S += 1;
DROP += 1;
}
}
}
fn f(ref _s: S) {}
struct T { i: int }
impl Drop for T {
fn drop(&mut self) {
unsafe {
DROP_T += 1;
DROP += 1;
}
}
}
f... | let ret = green::start(argc, argv, green::basic::event_loop, main);
unsafe {
assert_eq!(2, DROP);
assert_eq!(1, DROP_S);
assert_eq!(1, DROP_T); | random_line_split |
issue-8860.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... | (&mut self) {
unsafe {
DROP_T += 1;
DROP += 1;
}
}
}
fn g(ref _t: T) {}
fn main() {
let s = S;
f(s);
unsafe {
assert_eq!(1, DROP);
assert_eq!(1, DROP_S);
}
let t = T { i: 1 };
g(t);
unsafe { assert_eq!(1, DROP_T); }
}
| drop | identifier_name |
virt_addr.rs | // SPDX-License-Identifier: Unlicense
//! Type-checked virtual addresses.
//!
//! ```rust
//! let a = 3;
//! ```
use super::{Addr, AddrRange, PhysAddr, PhysAddrRange, PAGESIZE_BYTES};
use core::fmt::{Debug, Error, Formatter};
/// A local (if kernel range), or a cluster-wide (if low range) virtual address.
#[derive(... | }
/// Construct bottom of virtual address range.
pub const fn null() -> Self {
Self(0)
}
/// Create a virtual address from a physical address.
///
/// UNSAFE: virtual address can only be derefed when identity mapping is in place
/// before paging is enabled or if physical memor... | Self(sym as usize) | random_line_split |
virt_addr.rs | // SPDX-License-Identifier: Unlicense
//! Type-checked virtual addresses.
//!
//! ```rust
//! let a = 3;
//! ```
use super::{Addr, AddrRange, PhysAddr, PhysAddrRange, PAGESIZE_BYTES};
use core::fmt::{Debug, Error, Formatter};
/// A local (if kernel range), or a cluster-wide (if low range) virtual address.
#[derive(... |
fn length(&self) -> usize {
self.length
}
}
impl VirtAddrRange {
/// Create a range from static refs.
pub fn from_linker_symbols(sym_base: *const u8, sym_top: *const u8) -> Self {
let base = VirtAddr::from_linker_symbol(sym_base);
let top = VirtAddr::from_linker_symbol(sym_top... | {
self.base
} | identifier_body |
virt_addr.rs | // SPDX-License-Identifier: Unlicense
//! Type-checked virtual addresses.
//!
//! ```rust
//! let a = 3;
//! ```
use super::{Addr, AddrRange, PhysAddr, PhysAddrRange, PAGESIZE_BYTES};
use core::fmt::{Debug, Error, Formatter};
/// A local (if kernel range), or a cluster-wide (if low range) virtual address.
#[derive(... | (&self) -> usize {
self.0
}
}
impl VirtAddr {
/// Const for compile-time constant
pub const fn fixed(addr: usize) -> Self {
Self(addr)
}
/// Construct from a reference to a linker symbol.
pub fn from_linker_symbol(sym: *const u8) -> Self {
Self(sym as usize)
}
... | get | identifier_name |
player.rs |
use std::collections::LinkedList;
use application::gps_location::GpsLocation;
#[derive(Hash, Clone, Eq, PartialEq, Debug)]
pub struct Player {
name: String,
icon_path: String,
target: Option<Box<Player>>,
targeting_players: LinkedList<Box<Player>>,
location: GpsLocation,
score: i32,
}
impl Pl... |
}
| {
return &self.name;
} | identifier_body |
player.rs | use std::collections::LinkedList;
use application::gps_location::GpsLocation;
#[derive(Hash, Clone, Eq, PartialEq, Debug)]
pub struct Player {
name: String,
icon_path: String,
target: Option<Box<Player>>,
targeting_players: LinkedList<Box<Player>>,
location: GpsLocation,
score: i32,
}
impl Pla... | };
return player;
}
pub fn increment_score(&mut self) {
self.score += 1;
}
pub fn get_score(&self) -> i32 {
return self.score;
}
pub fn get_name(&self) -> &String {
return &self.name;
}
} | random_line_split | |
player.rs |
use std::collections::LinkedList;
use application::gps_location::GpsLocation;
#[derive(Hash, Clone, Eq, PartialEq, Debug)]
pub struct Player {
name: String,
icon_path: String,
target: Option<Box<Player>>,
targeting_players: LinkedList<Box<Player>>,
location: GpsLocation,
score: i32,
}
impl Pl... | (&self) -> i32 {
return self.score;
}
pub fn get_name(&self) -> &String {
return &self.name;
}
}
| get_score | identifier_name |
small_vector.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... | () -> SmallVector<T> {
SmallVector { repr: Zero }
}
pub fn one(v: T) -> SmallVector<T> {
SmallVector { repr: One(v) }
}
pub fn many(vs: Vec<T>) -> SmallVector<T> {
SmallVector { repr: Many(vs) }
}
pub fn as_slice<'a>(&'a self) -> &'a [T] {
match self.repr {
... | zero | identifier_name |
small_vector.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... |
pub fn push(&mut self, v: T) {
match self.repr {
Zero => self.repr = One(v),
One(..) => {
let one = mem::replace(&mut self.repr, Zero);
match one {
One(v1) => mem::replace(&mut self.repr, Many(vec!(v1, v))),
_ ... | {
match self.repr {
Zero => {
let result: &[T] = &[];
result
}
One(ref v) => slice::ref_slice(v),
Many(ref vs) => vs.as_slice()
}
} | identifier_body |
small_vector.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<T> Extend<T> for SmallVector<T> {
fn extend<I: Iterator<T>>(&mut self, mut iter: I) {
for val in iter {
self.push(val);
}
}
}
impl<T> SmallVector<T> {
pub fn zero() -> SmallVector<T> {
SmallVector { repr: Zero }
}
pub fn one(v: T) -> SmallVector<T> {
... | v.extend(iter);
v
}
}
| random_line_split |
query.rs | //! Values computed by queries that use MIR.
use crate::mir::{Body, Promoted};
use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set... | else {
self.mir_const_qualif(def.did)
}
}
#[inline]
pub fn promoted_mir_opt_const_arg(
self,
def: ty::WithOptConstParam<DefId>,
) -> &'tcx IndexVec<Promoted, Body<'tcx>> {
if let Some((did, param_did)) = def.as_const_arg() {
self.promoted_mir_of_... | {
self.mir_const_qualif_const_arg((def.did, param_did))
} | conditional_block |
query.rs | //! Values computed by queries that use MIR.
use crate::mir::{Body, Promoted};
use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set... | Return(ReturnConstraint),
Yield,
UseAsConst,
UseAsStatic,
TypeAnnotation,
Cast,
/// A constraint that came from checking the body of a closure.
///
/// We try to get the category that the closure used when reporting this.
ClosureBounds,
CallArgument,
CopyBound,
Sized... | #[derive(TyEncodable, TyDecodable, HashStable)]
pub enum ConstraintCategory { | random_line_split |
query.rs | //! Values computed by queries that use MIR.
use crate::mir::{Body, Promoted};
use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set... |
#[inline]
pub fn mir_for_ctfe_opt_const_arg(self, def: ty::WithOptConstParam<DefId>) -> &'tcx Body<'tcx> {
if let Some((did, param_did)) = def.as_const_arg() {
self.mir_for_ctfe_of_const_arg((did, param_did))
} else {
self.mir_for_ctfe(def.did)
}
}
}
| {
if let Some((did, param_did)) = def.as_const_arg() {
self.promoted_mir_of_const_arg((did, param_did))
} else {
self.promoted_mir(def.did)
}
} | identifier_body |
query.rs | //! Values computed by queries that use MIR.
use crate::mir::{Body, Promoted};
use crate::ty::{self, Ty, TyCtxt};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::vec_map::VecMap;
use rustc_errors::ErrorReported;
use rustc_hir as hir;
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set... | <T>(T);
impl<T: Debug> Debug for OneLinePrinter<T> {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{:?}", self.0)
}
}
fmt.debug_struct("GeneratorLayout")
.field("field_tys", &MapPrinter::new(self.field_tys.iter_enume... | OneLinePrinter | identifier_name |
mem.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/.
//! Memory operations.
pub use lrs_core::mem::{
uninit, cast, zeroed, copy_as, forget, unsafe_forget, drop, copy... |
#[cfg(not(freestanding))]
pub use lrs_mem::flags::{MemLockFlags};
#[cfg(not(freestanding))]
pub mod advice {
pub use lrs_mem::adv::{
Normal, Random, Sequential, WillNeed, DontNeed, Remove, DontFork, DoFork,
HwPoison, SoftOffline, Mergeable, Unmergeable, HugePage, NoHugePage, DontDump,
DoDu... | pub use lrs_mem::{
advise, protect, lock, unlock, lock_all, unlock_all, Availability, availability,
}; | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.