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
lib.rs
extern crate chrono; extern crate copy_dir; #[macro_use] extern crate error_chain; #[macro_use] extern crate log; extern crate regex; #[macro_use] extern crate serde_derive; extern crate shlex; extern crate tempdir; #[cfg(test)] extern crate toml; pub mod errors; mod config; #[macro_use] pub mod helpers; use std::pa...
/// Generate the documentation for the specified library in a local checkout /// of the rust repo. fn generate_docs(root: &Path) -> Result<()> { cmd!(in root, "./x.py doc -v")?; Ok(()) } fn upload_docs(root: &Path, git_repo: &str) -> Result<()> { // FIXME: should probably not hard-code this... let ta...
{ info!("Starting documentation generation"); if !cfg.stages.skip_git_update { update_rust_repo(&cfg.rust_dir).chain_err(|| "Failed to update the rust repo")?; } setup_rustbuild_config_file(&cfg.rust_dir) .chain_err(|| "Couldn't make sure the config.toml is set properly")?; info!("...
identifier_body
lib.rs
extern crate chrono; extern crate copy_dir; #[macro_use] extern crate error_chain; #[macro_use] extern crate log; extern crate regex; #[macro_use] extern crate serde_derive; extern crate shlex; extern crate tempdir; #[cfg(test)] extern crate toml; pub mod errors; mod config; #[macro_use] pub mod helpers; use std::pa...
.write_all(config_contents.as_bytes()) .chain_err(|| "Couldn't write to config.toml")?; Ok(()) }
debug!("Config file: {}", config_file.display()); File::create(&config_file) .expect("Config file should already exist")
random_line_split
lib.rs
extern crate chrono; extern crate copy_dir; #[macro_use] extern crate error_chain; #[macro_use] extern crate log; extern crate regex; #[macro_use] extern crate serde_derive; extern crate shlex; extern crate tempdir; #[cfg(test)] extern crate toml; pub mod errors; mod config; #[macro_use] pub mod helpers; use std::pa...
debug!("Pushing to GitHub pages"); cmd!(in temp.path(), "git add.")?; cmd!(in temp.path(), r#"git commit -m "updated documentation at {}""#, Local::now())?; cmd!(in temp.path(), "git push origin gh-pages")?; debug!("Docs uploaded"); Ok(()) } /// Do a `git clone` or `git pull` to make sure th...
{ let redirect = r#"<html><meta http-equiv="refresh" content="0; URL=rustc/index.html"></html>"#; File::create(index)?.write_all(redirect.as_bytes())?; }
conditional_block
packet_builder.rs
use packet::Packet; use packet; use std::cmp; use std::iter::Iterator; const PACKET_SIZE: usize = 1024; const PACKET_HEADER_SIZE: usize = 8; const PACKET_DATA_SIZE: usize = PACKET_SIZE - PACKET_HEADER_SIZE; pub struct PacketBuilder<'a> { packet_count: usize, packet_type: packet::Type, data: Option<&'a Vec...
(packet_type: packet::Type, data: Option<&'a Vec<u8>>) -> Self { let count = match data { Some(d) => Self::get_packet_count(d.len()), None => 1, }; PacketBuilder { packet_count: count, packet_type: packet_type, data: dat...
new
identifier_name
packet_builder.rs
use packet::Packet; use packet; use std::cmp; use std::iter::Iterator; const PACKET_SIZE: usize = 1024; const PACKET_HEADER_SIZE: usize = 8; const PACKET_DATA_SIZE: usize = PACKET_SIZE - PACKET_HEADER_SIZE; pub struct PacketBuilder<'a> { packet_count: usize, packet_type: packet::Type, data: Option<&'a Vec...
} let len = packet.data.len().clone(); packet.set_length(len as u16); packet.set_id(self.position as u8); Some(packet) } } impl<'a> PacketBuilder<'a> { pub fn new(packet_type: packet::Type, data: Option<&'a Vec<u8>>) -> Self { let count = match ...
{ self.position += 1; if self.position > self.packet_builder.packet_count { return None; } let mut packet = Packet::new(); // TODO: make sure we handle no-data packets correctly if let Some(data) = self.packet_builder.data { let start_pos = (self....
identifier_body
packet_builder.rs
use packet::Packet; use packet; use std::cmp; use std::iter::Iterator; const PACKET_SIZE: usize = 1024; const PACKET_HEADER_SIZE: usize = 8; const PACKET_DATA_SIZE: usize = PACKET_SIZE - PACKET_HEADER_SIZE; pub struct PacketBuilder<'a> { packet_count: usize, packet_type: packet::Type, data: Option<&'a Vec...
packet.set_type(&self.packet_builder.packet_type); if self.position == self.packet_builder.packet_count { packet.toggle_status(&packet::Status::EOM); } let len = packet.data.len().clone(); packet.set_length(len as u16); packet.set_id(self.position as u8); ...
random_line_split
spirv.rs
use super::{InlineAsmArch, InlineAsmType}; use rustc_macros::HashStable_Generic; def_reg_class! { SpirV SpirVInlineAsmRegClass { reg, } } impl SpirVInlineAsmRegClass { pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] { &[] } pub fn
(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> { None } pub fn suggest_modifier( self, _arch: InlineAsmArch, _ty: InlineAsmType, ) -> Option<(char, &'static str)> { None } pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char,...
suggest_class
identifier_name
spirv.rs
use super::{InlineAsmArch, InlineAsmType}; use rustc_macros::HashStable_Generic; def_reg_class! { SpirV SpirVInlineAsmRegClass { reg, } }
&[] } pub fn suggest_class(self, _arch: InlineAsmArch, _ty: InlineAsmType) -> Option<Self> { None } pub fn suggest_modifier( self, _arch: InlineAsmArch, _ty: InlineAsmType, ) -> Option<(char, &'static str)> { None } pub fn default_modifier(s...
impl SpirVInlineAsmRegClass { pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] {
random_line_split
spirv.rs
use super::{InlineAsmArch, InlineAsmType}; use rustc_macros::HashStable_Generic; def_reg_class! { SpirV SpirVInlineAsmRegClass { reg, } } impl SpirVInlineAsmRegClass { pub fn valid_modifiers(self, _arch: super::InlineAsmArch) -> &'static [char] { &[] } pub fn suggest_class(self, _...
pub fn suggest_modifier( self, _arch: InlineAsmArch, _ty: InlineAsmType, ) -> Option<(char, &'static str)> { None } pub fn default_modifier(self, _arch: InlineAsmArch) -> Option<(char, &'static str)> { None } pub fn supported_types( self, ...
{ None }
identifier_body
kindck-send-region-pointers.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn test21<'a>(_: &'a int) { assert_send::<&'a str>(); //~ ERROR declared lifetime bound not satisfied } fn test22<'a>(_: &'a int) { assert_send::<&'a [int]>(); //~ ERROR declared lifetime bound not satisfied } fn main() { }
{ assert_send::<&'a int>(); //~ ERROR declared lifetime bound not satisfied }
identifier_body
kindck-send-region-pointers.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
fn main() { }
random_line_split
kindck-send-region-pointers.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a>(_: &'a int) { assert_send::<&'a str>(); //~ ERROR declared lifetime bound not satisfied } fn test22<'a>(_: &'a int) { assert_send::<&'a [int]>(); //~ ERROR declared lifetime bound not satisfied } fn main() { }
test21
identifier_name
nullable-pointer-size.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 ...
() { check_type!(&'static int); check_type!(~int); check_type!(@int); check_type!(~str); check_type!(@str); check_type!(~[int]); check_type!(@[int]); check_type!(extern fn()); }
main
identifier_name
nullable-pointer-size.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 ...
}} } pub fn main() { check_type!(&'static int); check_type!(~int); check_type!(@int); check_type!(~str); check_type!(@str); check_type!(~[int]); check_type!(@[int]); check_type!(extern fn()); }
macro_rules! check_type { ($T:ty) => {{ check_option!($T); check_fancy!($T);
random_line_split
builder.rs
use std::default::Default; use errors::*; use feed::{Feed, Author, Attachment}; use item::{Content, Item}; /// Feed Builder /// /// This is used to programmatically build up a Feed object, /// which can be serialized later into a JSON string pub struct Builder(Feed); impl Builder { pub fn new() -> Builder { ...
{ pub id: Option<String>, pub url: Option<String>, pub external_url: Option<String>, pub title: Option<String>, pub content: Option<Content>, pub summary: Option<String>, pub image: Option<String>, pub banner_image: Option<String>, pub date_published: Option<String>, pub date_mo...
ItemBuilder
identifier_name
builder.rs
use std::default::Default; use errors::*; use feed::{Feed, Author, Attachment}; use item::{Content, Item}; /// Feed Builder /// /// This is used to programmatically build up a Feed object, /// which can be serialized later into a JSON string pub struct Builder(Feed); impl Builder { pub fn new() -> Builder { ...
self } pub fn build(self) -> Feed { self.0 } } /// Builder object for an item in a feed pub struct ItemBuilder { pub id: Option<String>, pub url: Option<String>, pub external_url: Option<String>, pub title: Option<String>, pub content: Option<Content>, pub summary:...
self } pub fn item(mut self, item: Item) -> Builder { self.0.items.push(item);
random_line_split
builder.rs
use std::default::Default; use errors::*; use feed::{Feed, Author, Attachment}; use item::{Content, Item}; /// Feed Builder /// /// This is used to programmatically build up a Feed object, /// which can be serialized later into a JSON string pub struct Builder(Feed); impl Builder { pub fn new() -> Builder { ...
, } self } pub fn build(self) -> Result<Item> { if self.id.is_none() || self.content.is_none() { return Err("missing field 'id' or 'content_*'".into()); } Ok(Item { id: self.id.unwrap(), url: self.url, external_url: self.ex...
{ self.content = Some(Content::Text(i.into())); }
conditional_block
builder.rs
use std::default::Default; use errors::*; use feed::{Feed, Author, Attachment}; use item::{Content, Item}; /// Feed Builder /// /// This is used to programmatically build up a Feed object, /// which can be serialized later into a JSON string pub struct Builder(Feed); impl Builder { pub fn new() -> Builder { ...
pub fn content_html<I: Into<String>>(mut self, i: I) -> ItemBuilder { match self.content { Some(Content::Text(t)) => { self.content = Some(Content::Both(i.into(), t)); }, _ => { self.content = Some(Content::Html(i.into())); } ...
{ self.title = Some(i.into()); self }
identifier_body
extern-return-TwoU64s.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 ...
{ unsafe { let y = rust_dbg_extern_return_TwoU64s(); assert_eq!(y.one, 10); assert_eq!(y.two, 20); } }
identifier_body
extern-return-TwoU64s.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 ...
{ one: u64, two: u64 } extern { pub fn rust_dbg_extern_return_TwoU64s() -> TwoU64s; } #[fixed_stack_segment] #[inline(never)] pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU64s(); assert_eq!(y.one, 10); assert_eq!(y.two, 20); } }
TwoU64s
identifier_name
extern-return-TwoU64s.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 rust_dbg_extern_return_TwoU64s() -> TwoU64s; } #[fixed_stack_segment] #[inline(never)] pub fn main() { unsafe { let y = rust_dbg_extern_return_TwoU64s(); assert_eq!(y.one, 10); assert_eq!(y.two, 20); } }
extern {
random_line_split
traits.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
() -> DBTransaction { DBTransaction { writes: RefCell::new(Vec::new()), removes: RefCell::new(Vec::new()), } } pub fn put(&self, key: &[u8], value: &[u8]) { let mut brw = self.writes.borrow_mut(); brw.push(KeyValue { key: key.to_vec(), value: value.to_vec() }); } pub fn delete(&self, key: &[u8]) { ...
new
identifier_name
traits.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
} pub trait DatabaseService : Sized { /// Opens database in the specified path fn open(&self, config: DatabaseConfig, path: String) -> Result<(), Error>; /// Opens database in the specified path with the default config fn open_default(&self, path: String) -> Result<(), Error>; /// Closes database fn close(&se...
{ DatabaseConfig { prefix_size: Some(prefix), cache: DEFAULT_CACHE_LEN, } }
identifier_body
traits.rs
// Copyright 2015-2017 Parity Technologies (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 lat...
} } pub trait DatabaseService : Sized { /// Opens database in the specified path fn open(&self, config: DatabaseConfig, path: String) -> Result<(), Error>; /// Opens database in the specified path with the default config fn open_default(&self, path: String) -> Result<(), Error>; /// Closes database fn close(&...
}
random_line_split
part04.rs
// Rust-101, Part 04: Ownership, Borrowing, References // =================================================== /* void foo(std::vector<int> v) { int *first = &v[0]; v.push_back(42); *first = 1337; // This is bad! } */ // ## Ownership fn work_on_vector(v: Vec<i32>) { /* do something */ } fn
() { let v = vec![1,2,3,4]; work_on_vector(v); /* println!("The first element is: {}", v[0]); */ /* BAD! */ } // ## Borrowing a shared reference fn vec_min(v: &Vec<i32>) -> Option<i32> { use std::cmp; let mut min = None; // This time, we explicitly request an iterator for the ve...
ownership_demo
identifier_name
part04.rs
// Rust-101, Part 04: Ownership, Borrowing, References // =================================================== /* void foo(std::vector<int> v) { int *first = &v[0]; v.push_back(42); *first = 1337; // This is bad! } */ // ## Ownership fn work_on_vector(v: Vec<i32>) { /* do something */ } fn owners...
// The ownership and borrowing system of Rust enforces the following three rules: // // * There is always exactly one owner of a piece of data // * If there is an active mutable reference, then nobody else can have active access to the data // * If there is an active shared reference, then every other active access to...
random_line_split
part04.rs
// Rust-101, Part 04: Ownership, Borrowing, References // =================================================== /* void foo(std::vector<int> v) { int *first = &v[0]; v.push_back(42); *first = 1337; // This is bad! } */ // ## Ownership fn work_on_vector(v: Vec<i32>) { /* do something */ } fn owners...
// ## Unique, mutable references fn vec_inc(v: &mut Vec<i32>) { for e in v.iter_mut() { *e += 1; } } // Here's an example of calling `vec_inc`. fn mutable_ref_demo() { let mut v = vec![5,4,3,2,1]; /* let first = &v[0]; */ vec_inc(&mut v); vec_inc(&mut v); /* println!("The first el...
{ let v = vec![5,4,3,2,1]; let first = &v[0]; vec_min(&v); vec_min(&v); println!("The first element is: {}", *first); }
identifier_body
advanced.rs
extern crate rspec; use std::collections::BTreeSet; pub fn main() { #[derive(Clone, Debug)] struct Environment { set: BTreeSet<usize>, len_before: usize, } let environment = Environment { set: BTreeSet::new(), len_before: 0, }; rspec::run(&rspec::given("a BTre...
env.set.insert(42); }); ctx.then("its len remains the same", |env| { assert_eq!(env.set.len(), env.len_before); }); }); }); ctx.when("returning to outer context", |ctx| { ctx.then("it is sti...
ctx.when("adding it again", |ctx| { ctx.before_all(|env| { env.len_before = env.set.len();
random_line_split
advanced.rs
extern crate rspec; use std::collections::BTreeSet; pub fn main()
env.set.insert(42); }); ctx.then("it is not empty any more", |env| { assert!(!env.set.is_empty()); }); ctx.then("its len increases by 1", |env| { assert_eq!(env.set.len(), env.len_before + 1); }); ...
{ #[derive(Clone, Debug)] struct Environment { set: BTreeSet<usize>, len_before: usize, } let environment = Environment { set: BTreeSet::new(), len_before: 0, }; rspec::run(&rspec::given("a BTreeSet", environment, |ctx| { ctx.when("not having added any i...
identifier_body
advanced.rs
extern crate rspec; use std::collections::BTreeSet; pub fn main() { #[derive(Clone, Debug)] struct
{ set: BTreeSet<usize>, len_before: usize, } let environment = Environment { set: BTreeSet::new(), len_before: 0, }; rspec::run(&rspec::given("a BTreeSet", environment, |ctx| { ctx.when("not having added any items", |ctx| { ctx.then("it is empty", |...
Environment
identifier_name
main.rs
#[derive(Debug)] struct Rectangle { width: u32, height: u32, }
// their name, they can have parameters and a return value, and they contain // some code that is run when they’re called from somewhere else. However, // methods are different from functions in that they’re defined within the // context of a struct (or an enum or a trait object, which we cover in Chapters // 6 and 17,...
// Methods are similar to functions: they’re declared with the fn keyword and
random_line_split
main.rs
#[derive(Debug)] struct Rectangle { width: u32, height: u32, } // Methods are similar to functions: they’re declared with the fn keyword and // their name, they can have parameters and a return value, and they contain // some code that is run when they’re called from somewhere else. However, // methods are di...
) -> u32 { self.width * self.height } fn can_hold($self, other: &Rectangle) -> bool { self.width > other.width && self.height > other.height } } fn main() { let rect1 = Rectangle { width: 30, height: 50 }; println!("The area of the Rectangle is {} square pixels.", rec...
self
identifier_name
main.rs
#[derive(Debug)] struct Rectangle { width: u32, height: u32, } // Methods are similar to functions: they’re declared with the fn keyword and // their name, they can have parameters and a return value, and they contain // some code that is run when they’re called from somewhere else. However, // methods are di...
main() { let rect1 = Rectangle { width: 30, height: 50 }; println!("The area of the Rectangle is {} square pixels.", rect1.area() ); let rect2 = Rectangle { width: 10, height: 40 }; let rect3 = Rectangle { width: 60, height: 45 }; println!("Can rect1 hold rect2? {}", rect1.can_h...
self.width > other.width && self.height > other.height } } fn
identifier_body
mod.rs
//! Traits, helpers, and type definitions for Card functionality. //! //! The `libterminal_cribbage::cards` module contains a number of common things you will need when //! using cards during the game. //! //! ## Card, Rank, and Suit //! //! With all card games, using the standard playing cards, each [`Card`] reference...
//! //! assert_eq!(playing_card.suit, other_playing_card.suit); //! //! let score = match playing_card.rank { //! Rank::Ace => 1, //! Rank::Two => 2, //! Rank::Three => 3, //! Rank::Four => 4, //! Rank::Five => 5, //! Rank::Six => 6, //! Rank::Seven => 7, //! Rank::Eight => 8, //! Ra...
//! use libterminal_cribbage::cards::{Card, Rank, Suit}; //! //! let playing_card = Card::new(Rank::Ace, Suit::Clubs); //! let other_playing_card = Card::new(Rank::Eight, Suit::Clubs);
random_line_split
interaction.rs
//! Models for Pact interactions use std::fmt::{self, Debug, Display, Formatter}; use std::sync::{Arc, Mutex}; use serde_json::Value; use crate::bodies::OptionalBody; use crate::content_types::ContentType; use crate::matchingrules::MatchingRules; use crate::message::Message; use crate::PactSpecification; use crate::...
/// Struct that defined an interaction conflict #[derive(Debug, Clone)] pub struct PactConflict { /// Description of the interactions pub interaction: String, /// Conflict description pub description: String } /// Interaction Trait pub trait Interaction: Debug { /// The type of the interaction fn type_of(&...
random_line_split
interaction.rs
//! Models for Pact interactions use std::fmt::{self, Debug, Display, Formatter}; use std::sync::{Arc, Mutex}; use serde_json::Value; use crate::bodies::OptionalBody; use crate::content_types::ContentType; use crate::matchingrules::MatchingRules; use crate::message::Message; use crate::PactSpecification; use crate::...
} } /// Converts the JSON struct into an HTTP Interaction pub fn http_interaction_from_json(source: &str, json: &Value, spec: &PactSpecification) -> anyhow::Result<Box<dyn Interaction + Send + Sync>> { match spec { PactSpecification::V4 => interaction_from_json(source, 0, json) .map(|i| i.boxed()), ...
{ panic!("Internal Error - Tried to clone an interaction that was not valid") }
conditional_block
interaction.rs
//! Models for Pact interactions use std::fmt::{self, Debug, Display, Formatter}; use std::sync::{Arc, Mutex}; use serde_json::Value; use crate::bodies::OptionalBody; use crate::content_types::ContentType; use crate::matchingrules::MatchingRules; use crate::message::Message; use crate::PactSpecification; use crate::...
(&self) -> Self { if self.is_v4() { if let Some(http) = self.as_v4_http() { Box::new(http) } else if let Some(message) = self.as_v4_async_message() { Box::new(message) } else { panic!("Internal Error - Tried to clone an interaction that was not valid") } } else if...
clone
identifier_name
interaction.rs
//! Models for Pact interactions use std::fmt::{self, Debug, Display, Formatter}; use std::sync::{Arc, Mutex}; use serde_json::Value; use crate::bodies::OptionalBody; use crate::content_types::ContentType; use crate::matchingrules::MatchingRules; use crate::message::Message; use crate::PactSpecification; use crate::...
/// Converts the JSON struct into a Message Interaction pub fn message_interaction_from_json(source: &str, json: &Value, spec: &PactSpecification) -> anyhow::Result<Box<dyn Interaction + Send + Sync>> { match spec { PactSpecification::V4 => interaction_from_json(source, 0, json) .map(|i| i.boxed()), _ ...
{ match spec { PactSpecification::V4 => interaction_from_json(source, 0, json) .map(|i| i.boxed()), _ => Ok(Box::new(RequestResponseInteraction::from_json(0, json, spec)?)) } }
identifier_body
upload_dif.rs
//! Implements a command for uploading dSYM files. use std::collections::BTreeSet; use std::env; use std::str::{self, FromStr}; use clap::{App, Arg, ArgMatches}; use console::style; use failure::{bail, err_msg, Error}; use log::info; use symbolic::common::DebugId; use symbolic::debuginfo::FileFormat; use crate::api::...
(matches: &ArgMatches<'_>) -> Result<(), Error> { execute_internal(matches, true) }
execute_legacy
identifier_name
upload_dif.rs
//! Implements a command for uploading dSYM files. use std::collections::BTreeSet; use std::env; use std::str::{self, FromStr}; use clap::{App, Arg, ArgMatches}; use console::style; use failure::{bail, err_msg, Error}; use log::info; use symbolic::common::DebugId; use symbolic::debuginfo::FileFormat; use crate::api::...
) .arg( Arg::with_name("no_debug") .long("no-debug") .help( "Do not scan for debugging information. This will \ usually exclude debug companion files. They might \ still be uploaded, if they contain ad...
still be uploaded, if they contain additional \ processable information (see other flags).", ),
random_line_split
upload_dif.rs
//! Implements a command for uploading dSYM files. use std::collections::BTreeSet; use std::env; use std::str::{self, FromStr}; use clap::{App, Arg, ArgMatches}; use console::style; use failure::{bail, err_msg, Error}; use log::info; use symbolic::common::DebugId; use symbolic::debuginfo::FileFormat; use crate::api::...
} } // Try to resolve the Info.plist either by path or from Xcode let info_plist = match matches.value_of("info_plist") { Some(path) => Some(InfoPlist::from_path(path)?), None => InfoPlist::discover_from_env()?, }; if matches.is_present("no_upload") { println!("{} ...
{ upload.search_path(path); }
conditional_block
upload_dif.rs
//! Implements a command for uploading dSYM files. use std::collections::BTreeSet; use std::env; use std::str::{self, FromStr}; use clap::{App, Arg, ArgMatches}; use console::style; use failure::{bail, err_msg, Error}; use log::info; use symbolic::common::DebugId; use symbolic::debuginfo::FileFormat; use crate::api::...
"elf", "breakpad", "pdb", "pe", "sourcebundle", "bcsymbolmap", ]) .help( "Only consider debug information files of the given \ t...
{ app.about("Upload debugging information files.") .org_project_args() .arg( Arg::with_name("paths") .value_name("PATH") .help("A path to search recursively for symbol files.") .multiple(true) .number_of_values(1) ...
identifier_body
autoref-intermediate-types-issue-3585.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 x = box(GC) 3u; assert_eq!(x.foo(), "box(GC) 3".to_string()); }
main
identifier_name
autoref-intermediate-types-issue-3585.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 x = box(GC) 3u; assert_eq!(x.foo(), "box(GC) 3".to_string());
random_line_split
autoref-intermediate-types-issue-3585.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} impl Foo for uint { fn foo(&self) -> String { format!("{}", *self) } } pub fn main() { let x = box(GC) 3u; assert_eq!(x.foo(), "box(GC) 3".to_string()); }
{ format!("box(GC) {}", (**self).foo()) }
identifier_body
dompointreadonly.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::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap}; use dom::bindings:...
// https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-z fn Z(&self) -> f64 { self.z.get() } // https://dev.w3.org/fxtf/geometry/Overview.html#dom-dompointreadonly-w fn W(&self) -> f64 { self.w.get() } } pub trait DOMPointWriteMethods { fn SetX(&self, valu...
{ self.y.get() }
identifier_body
dompointreadonly.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::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap}; use dom::bindings:...
self.w.get() } } pub trait DOMPointWriteMethods { fn SetX(&self, value: f64); fn SetY(&self, value: f64); fn SetZ(&self, value: f64); fn SetW(&self, value: f64); } impl DOMPointWriteMethods for DOMPointReadOnly { fn SetX(&self, value: f64) { self.x.set(value); } fn Set...
fn W(&self) -> f64 {
random_line_split
dompointreadonly.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::Bindings::DOMPointReadOnlyBinding::{DOMPointReadOnlyMethods, Wrap}; use dom::bindings:...
(&self, value: f64) { self.y.set(value); } fn SetZ(&self, value: f64) { self.z.set(value); } fn SetW(&self, value: f64) { self.w.set(value); } }
SetY
identifier_name
bitv-perf-test.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...
#![allow(unknown_features)] #![feature(box_syntax)] extern crate collections; use std::collections::BitVec; fn bitv_test() { let mut v1: Box<_> = box BitVec::from_elem(31, false); let v2: Box<_> = box BitVec::from_elem(31, true); v1.union(&*v2); } pub fn main() { for _ in 0..10000 { bitv_test(); } }
// option. This file may not be copied, modified, or distributed // except according to those terms.
random_line_split
bitv-perf-test.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-M...
{ for _ in 0..10000 { bitv_test(); } }
identifier_body
bitv-perf-test.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-M...
() { for _ in 0..10000 { bitv_test(); } }
main
identifier_name
trait-coercion-generic-regions.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. struct Struct { person: &'static str } trait Trait<T> { fn f(&self, x: T); } ...
random_line_split
trait-coercion-generic-regions.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 ...
{ person: &'static str } trait Trait<T> { fn f(&self, x: T); } impl Trait<&'static str> for Struct { fn f(&self, x: &'static str) { println!("Hello, {}!", x); } } fn main() { let person = "Fred".to_owned(); let person: &str = person; //~ ERROR `person[..]` does not live long enough ...
Struct
identifier_name
epoll.rs
use crate::Result; use crate::errno::Errno; use libc::{self, c_int}; use std::os::unix::io::RawFd; use std::ptr; use std::mem; use crate::Error; libc_bitflags!( pub struct EpollFlags: c_int { EPOLLIN; EPOLLPRI; EPOLLOUT; EPOLLRDNORM; EPOLLRDBAND; EPOLLWRNORM; ...
#[inline] pub fn epoll_wait(epfd: RawFd, events: &mut [EpollEvent], timeout_ms: isize) -> Result<usize> { let res = unsafe { libc::epoll_wait(epfd, events.as_mut_ptr() as *mut libc::epoll_event, events.len() as c_int, timeout_ms as c_int) }; Errno::result(res).map(|r| r as usize) }
{ let mut event: Option<&mut EpollEvent> = event.into(); if event.is_none() && op != EpollOp::EpollCtlDel { Err(Error::Sys(Errno::EINVAL)) } else { let res = unsafe { if let Some(ref mut event) = event { libc::epoll_ctl(epfd, op as c_int, fd, &mut event.event) ...
identifier_body
epoll.rs
use crate::Result; use crate::errno::Errno; use libc::{self, c_int}; use std::os::unix::io::RawFd; use std::ptr; use std::mem; use crate::Error; libc_bitflags!( pub struct EpollFlags: c_int { EPOLLIN; EPOLLPRI; EPOLLOUT; EPOLLRDNORM; EPOLLRDBAND; EPOLLWRNORM; ...
}; Errno::result(res).map(drop) } } #[inline] pub fn epoll_wait(epfd: RawFd, events: &mut [EpollEvent], timeout_ms: isize) -> Result<usize> { let res = unsafe { libc::epoll_wait(epfd, events.as_mut_ptr() as *mut libc::epoll_event, events.len() as c_int, timeout_ms as c_int) }; ...
{ libc::epoll_ctl(epfd, op as c_int, fd, ptr::null_mut()) }
conditional_block
epoll.rs
use crate::Result; use crate::errno::Errno; use libc::{self, c_int}; use std::os::unix::io::RawFd; use std::ptr; use std::mem; use crate::Error; libc_bitflags!( pub struct EpollFlags: c_int { EPOLLIN; EPOLLPRI; EPOLLOUT; EPOLLRDNORM; EPOLLRDBAND; EPOLLWRNORM; ...
Errno::result(res).map(drop) } } #[inline] pub fn epoll_wait(epfd: RawFd, events: &mut [EpollEvent], timeout_ms: isize) -> Result<usize> { let res = unsafe { libc::epoll_wait(epfd, events.as_mut_ptr() as *mut libc::epoll_event, events.len() as c_int, timeout_ms as c_int) }; Errno::resu...
} };
random_line_split
epoll.rs
use crate::Result; use crate::errno::Errno; use libc::{self, c_int}; use std::os::unix::io::RawFd; use std::ptr; use std::mem; use crate::Error; libc_bitflags!( pub struct EpollFlags: c_int { EPOLLIN; EPOLLPRI; EPOLLOUT; EPOLLRDNORM; EPOLLRDBAND; EPOLLWRNORM; ...
(&self) -> EpollFlags { EpollFlags::from_bits(self.event.events as c_int).unwrap() } pub fn data(&self) -> u64 { self.event.u64 } } #[inline] pub fn epoll_create() -> Result<RawFd> { let res = unsafe { libc::epoll_create(1024) }; Errno::result(res) } #[inline] pub fn epoll_create...
events
identifier_name
mod.rs
// Copyright 2018 Guanhao Yin <sopium@mysterious.site> // This file is part of TiTun. // TiTun 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 la...
pub mod commands; // Export for fuzzing. #[doc(hidden)] pub mod parse; mod server; mod wait_delete; pub use self::server::*;
// You should have received a copy of the GNU General Public License // along with TiTun. If not, see <https://www.gnu.org/licenses/>.
random_line_split
issue-50061.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 ...
() { //! this doc comment forces roundtrip through a string let checkit = 0; outer!(checkit); }
main
identifier_name
issue-50061.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 ...
{ //! this doc comment forces roundtrip through a string let checkit = 0; outer!(checkit); }
identifier_body
issue-51116.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 ...
//~| NOTE cannot infer type //~| NOTE type must be known at this point } } let tiles: [[usize; 3]; 3] = tiles; }
*tile = 0; //~^ ERROR type annotations needed
random_line_split
issue-51116.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 ...
() { let tiles = Default::default(); for row in &mut tiles { for tile in row { //~^ NOTE the element type for this iterator is not specified *tile = 0; //~^ ERROR type annotations needed //~| NOTE cannot infer type //~| NOTE type must be known ...
main
identifier_name
issue-51116.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 ...
{ let tiles = Default::default(); for row in &mut tiles { for tile in row { //~^ NOTE the element type for this iterator is not specified *tile = 0; //~^ ERROR type annotations needed //~| NOTE cannot infer type //~| NOTE type must be known at ...
identifier_body
range.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() -> int { 42 } pub fn main() { let mut count = 0; for i in 0u..10 { assert!(i >= 0 && i < 10); count += i; } assert!(count == 45); let mut count = 0; let mut range = 0u..10; for i in range { assert!(i >= 0 && i < 10); count += i; } assert!(count ==...
foo
identifier_name
range.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
count += i; } assert!(count == 45); let mut count = 0; let mut range = 0u..10; for i in range { assert!(i >= 0 && i < 10); count += i; } assert!(count == 45); let mut count = 0; let mut rf = 3u..; for i in rf.take(10) { assert!(i >= 3 && i < 13);...
pub fn main() { let mut count = 0; for i in 0u..10 { assert!(i >= 0 && i < 10);
random_line_split
range.rs
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn main() { let mut count = 0; for i in 0u..10 { assert!(i >= 0 && i < 10); count += i; } assert!(count == 45); let mut count = 0; let mut range = 0u..10; for i in range { assert!(i >= 0 && i < 10); count += i; } assert!(count == 45); let m...
{ 42 }
identifier_body
embedder.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/. */ //! Implements the global methods required by Servo (not window/gl/compositor related). use crate::events_loop::...
fn register_webxr( &mut self, xr: &mut webxr::MainThreadRegistry, _embedder_proxy: EmbedderProxy, ) { if pref!(dom.webxr.test) { xr.register_mock(webxr::headless::HeadlessMockDiscovery::new()); } else if let Some(xr_discovery) = self.xr_discovery.take() { ...
{ self.events_loop.borrow().create_event_loop_waker() }
identifier_body
embedder.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/. */ //! Implements the global methods required by Servo (not window/gl/compositor related). use crate::events_loop::...
(&mut self) -> Box<dyn EventLoopWaker> { self.events_loop.borrow().create_event_loop_waker() } fn register_webxr( &mut self, xr: &mut webxr::MainThreadRegistry, _embedder_proxy: EmbedderProxy, ) { if pref!(dom.webxr.test) { xr.register_mock(webxr::headles...
create_event_loop_waker
identifier_name
embedder.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/. */ //! Implements the global methods required by Servo (not window/gl/compositor related). use crate::events_loop::...
} }
{ xr.register(xr_discovery); }
conditional_block
embedder.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/. */ //! Implements the global methods required by Servo (not window/gl/compositor related). use crate::events_loop::...
xr.register(xr_discovery); } } }
random_line_split
button.rs
use std::fmt; /// The `MouseButton` type. Identifies mouse buttons for actions. pub enum MouseButton { Left, Middle, Right, ScrollUp, ScrollDown, } /// Buttons contain a `Vec` of `ClickAction`s and some text. Typically used as the `text` of a `Block`. pub struct Button { pub actions: Vec<Cl...
{ pub button: MouseButton, pub command: String, } impl fmt::Display for Button { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut content = self.text.to_string(); for action in self.actions.iter().rev() { content = format!("{}{}%{{A}}", action, content); ...
ClickAction
identifier_name
button.rs
use std::fmt; /// The `MouseButton` type. Identifies mouse buttons for actions. pub enum MouseButton { Left, Middle, Right, ScrollUp, ScrollDown, } /// Buttons contain a `Vec` of `ClickAction`s and some text. Typically used as the `text` of a `Block`. pub struct Button { pub actions: Vec<Cl...
} }
assert!(MouseButton::ScrollDown.to_string() == "5");
random_line_split
lib.rs
//! [`Layout`]: struct.Layout.html //! [RFC 1398]: https://github.com/rust-lang/rfcs/blob/master/text/1398-kinds-of-allocators.md //! [tracking issue]: https://github.com/rust-lang/rust/issues/32838 #![crate_name = "sos_alloc"] #![crate_type = "lib"] // The compiler needs to be instructed that this crate is an allocat...
//! For more information on the Allocator API, refer to: //! + the text of [RFC 1398] //! + rust-lang/rust [tracking issue] //! //! [`Allocator`]: trait.Allocator.html
random_line_split
lib.rs
in the array. /// /// On arithmetic overflow, returns `None`. pub fn repeat(&self, n: usize) -> Option<(Self, usize)> { let padded_size = match self.size.checked_add(self.padding_needed_for(self.align)) { None => return None, Some(padded_size) => padded_size, }; ...
realloc_unchecked
identifier_name
lib.rs
// like `posix_memalign` require it and it is a reasonable // constraint to impose on Layout constructors. // // (However, we do not analogously require `align >= sizeof(void*)`, // even though that is *also* a requirement of `posix_memalign`.) align: Alignment, } // FIXME: audit default imple...
/// Behaves like `fn realloc`, but also returns the whole size of /// the returned block. For some `layout` inputs, like arrays, this /// may include extra storage usable for additional data. unsafe fn realloc_excess(&mut self, ptr: Address, layout: ...
{ let usable_size = self.usable_size(&layout); self.alloc(layout).map(|p| Excess(p, usable_size.1)) }
identifier_body
time.rs
//! Timing is important for compositors and clients to know when to render //! frames. Most of these functions will be used for that purpose. use std::time::Duration; use crate::libc::{clock_gettime, timespec, CLOCK_MONOTONIC}; /// Trait to convert something to milliseconds. /// /// Used primarily to convert a `std:...
}
clock_gettime(CLOCK_MONOTONIC, &mut ts); Duration::new(ts.tv_sec as u64, ts.tv_nsec as u32) }
random_line_split
time.rs
//! Timing is important for compositors and clients to know when to render //! frames. Most of these functions will be used for that purpose. use std::time::Duration; use crate::libc::{clock_gettime, timespec, CLOCK_MONOTONIC}; /// Trait to convert something to milliseconds. /// /// Used primarily to convert a `std:...
(self) -> u32 { let seconds_delta = self.as_secs() as u32; let mili_delta = self.subsec_millis(); (seconds_delta * 1000) + mili_delta } } /// Get the current time as a duration suitable for functions such as /// `surface.send_frame_done()`. pub fn current_time() -> Duration { unsafe { ...
to_ms
identifier_name
time.rs
//! Timing is important for compositors and clients to know when to render //! frames. Most of these functions will be used for that purpose. use std::time::Duration; use crate::libc::{clock_gettime, timespec, CLOCK_MONOTONIC}; /// Trait to convert something to milliseconds. /// /// Used primarily to convert a `std:...
} /// Get the current time as a duration suitable for functions such as /// `surface.send_frame_done()`. pub fn current_time() -> Duration { unsafe { let mut ts = timespec { tv_sec: 0, tv_nsec: 0 }; clock_gettime(CLOCK_MONOTONIC, &mut ts); Duration::new(ts.t...
{ let seconds_delta = self.as_secs() as u32; let mili_delta = self.subsec_millis(); (seconds_delta * 1000) + mili_delta }
identifier_body
lint-unused-unsafe.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 ...
#[allow(unused_unsafe)] fn allowed() { unsafe {} } fn main() {}
} unsafe fn good3() { foo::bar() } fn good4() { unsafe { foo::bar() } }
random_line_split
lint-unused-unsafe.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 ...
//~ ERROR: unnecessary `unsafe` block fn bad6() { unsafe { // don't put the warning here unsafe { //~ ERROR: unnecessary `unsafe` block unsf() } } } unsafe fn bad7() { unsafe { //~ ERROR: unnecessa...
{ unsafe { unsf() } }
identifier_body
lint-unused-unsafe.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 bad1() { unsafe {} } //~ ERROR: unnecessary `unsafe` block fn bad2() { unsafe { bad1() } } //~ ERROR: unnecessary `unsafe` block unsafe fn bad3() { unsafe {} } //~ ERROR: unnecessary `unsafe` block fn bad4() { unsafe { callback(||{}) } } //~ ERROR: unnecessary `unsafe` blo...
unsf
identifier_name
build_gecko.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 super::PYTHON; use bindgen::{Builder, CodegenConfig}; use regex::Regex; use std::cmp; use std::collections::H...
fn handle_items<F>(self, key: &'static str, mut func: F) -> BuilderWithConfig<'a> where F: FnMut(Builder, &'a toml::Value) -> Builder, { self.handle_list(key, |b, iter| iter.fold(b, |b, item| func(b, item))) } fn handle_str_items<F>(self, key: &'static str, mut func: F) -> BuilderWi...
{ let mut builder = self.builder; let config = self.config; let mut used_keys = self.used_keys; if let Some(list) = config.get(key) { used_keys.insert(key); builder = func(builder, list.as_array().unwrap().as_slice().iter()); } BuilderWithConfig { ...
identifier_body
build_gecko.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 super::PYTHON; use bindgen::{Builder, CodegenConfig}; use regex::Regex; use std::cmp; use std::collections::H...
self.clang_arg("-include").clang_arg(file) } } struct Fixup { pat: String, rep: String, } fn write_binding_file(builder: Builder, file: &str, fixups: &[Fixup]) { let out_file = OUTDIR_PATH.join(file); if let Some(modified) = get_modified_time(&out_file) { // Don't generate the file...
random_line_split
build_gecko.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 super::PYTHON; use bindgen::{Builder, CodegenConfig}; use regex::Regex; use std::cmp; use std::collections::H...
let command_line_opts = builder.command_line_flags(); let result = builder.generate(); let mut result = match result { Ok(bindings) => bindings.to_string(), Err(_) => { panic!( "Failed to generate bindings, flags: {:?}", command_line_opts ...
{ // Don't generate the file if nothing it depends on was modified. let last_modified = LAST_MODIFIED.lock().unwrap(); if *last_modified <= modified { return; } }
conditional_block
build_gecko.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 super::PYTHON; use bindgen::{Builder, CodegenConfig}; use regex::Regex; use std::cmp; use std::collections::H...
(path: PathBuf, added_paths: &mut HashSet<PathBuf>) { if added_paths.contains(&path) { return; } let mut file = File::open(&path).unwrap(); let mut content = String::new(); file.read_to_string(&mut content).unwrap(); added_paths.insert(path); // Find all includes and add them recursi...
add_headers_recursively
identifier_name
instantiategenerics.rs
use std::collections::HashMap; use ast::*; use target::Target; use super::instantiate::instantiate; use super::typecheck::type_check_function; use super::typecheckercontext::{TypeCheckerContext, ImportSymbolResolver}; use compileerror::{CompileResult, unknown_name_result}; type FunctionMap = HashMap<String, Function>...
(ctx: &mut TypeCheckerContext, new_functions: &mut FunctionMap, imports: &ImportMap, module: &Module, call: &Call, target: &Target) -> CompileResult<()> { if let Some(func) = module.functions.get(&call.callee.name) { return do_instantiation(ctx, new_functions, func, module, call, target) } for impo...
resolve_generic_call
identifier_name
instantiategenerics.rs
use std::collections::HashMap; use ast::*; use target::Target; use super::instantiate::instantiate; use super::typecheck::type_check_function; use super::typecheckercontext::{TypeCheckerContext, ImportSymbolResolver}; use compileerror::{CompileResult, unknown_name_result}; type FunctionMap = HashMap<String, Function>...
fn resolve_generic_call(ctx: &mut TypeCheckerContext, new_functions: &mut FunctionMap, imports: &ImportMap, module: &Module, call: &Call, target: &Target) -> CompileResult<()> { if let Some(func) = module.functions.get(&call.callee.name) { return do_instantiation(ctx, new_functions, func, module, call, ta...
{ let name = new_func_name(&func.sig.name, &call.generic_args); if !new_functions.contains_key(&name) && !module.functions.contains_key(&name) { let mut new_func = instantiate(ctx, func, &call.generic_args)?; type_check_function(ctx, &mut new_func, target)?; new_functions.insert(name, ne...
identifier_body
instantiategenerics.rs
use std::collections::HashMap; use ast::*; use target::Target; use super::instantiate::instantiate; use super::typecheck::type_check_function; use super::typecheckercontext::{TypeCheckerContext, ImportSymbolResolver}; use compileerror::{CompileResult, unknown_name_result}; type FunctionMap = HashMap<String, Function>...
if!new_functions.contains_key(&name) &&!module.functions.contains_key(&name) { let mut new_func = instantiate(ctx, func, &call.generic_args)?; type_check_function(ctx, &mut new_func, target)?; new_functions.insert(name, new_func); } Ok(()) } fn resolve_generic_call(ctx: &mut TypeCh...
target: &Target) -> CompileResult<()> { let name = new_func_name(&func.sig.name, &call.generic_args);
random_line_split
instantiategenerics.rs
use std::collections::HashMap; use ast::*; use target::Target; use super::instantiate::instantiate; use super::typecheck::type_check_function; use super::typecheckercontext::{TypeCheckerContext, ImportSymbolResolver}; use compileerror::{CompileResult, unknown_name_result}; type FunctionMap = HashMap<String, Function>...
Ok(()) } fn resolve_generic_call(ctx: &mut TypeCheckerContext, new_functions: &mut FunctionMap, imports: &ImportMap, module: &Module, call: &Call, target: &Target) -> CompileResult<()> { if let Some(func) = module.functions.get(&call.callee.name) { return do_instantiation(ctx, new_functions, func, mo...
{ let mut new_func = instantiate(ctx, func, &call.generic_args)?; type_check_function(ctx, &mut new_func, target)?; new_functions.insert(name, new_func); }
conditional_block
idt.rs
use core::ptr; use x86; use x86::shared::dtables::*; use x86::current::irq::IdtEntry; use x86::shared::PrivilegeLevel; use x86::shared::paging::VAddr; extern "C" { static interrupt_handlers: [*const u8; 256]; } pub struct Idt { table: [IdtEntry; 256], } impl Idt { pub const fn new() -> Idt { Idt ...
() { x86::shared::irq::enable(); } pub unsafe fn disable() { x86::shared::irq::disable(); }
enable
identifier_name
idt.rs
use core::ptr; use x86; use x86::shared::dtables::*; use x86::current::irq::IdtEntry; use x86::shared::PrivilegeLevel; use x86::shared::paging::VAddr; extern "C" { static interrupt_handlers: [*const u8; 256]; } pub struct Idt { table: [IdtEntry; 256], } impl Idt { pub const fn new() -> Idt { Idt ...
} } } fn set_gate(&mut self, num: usize, handler: *const u8) { use x86::shared::segmentation::cs; if num!= 80 { self.table[num] = IdtEntry::new( VAddr::from_usize(handler as usize), cs().bits(), ...
{ self.set_gate(index, handler); }
conditional_block
idt.rs
use core::ptr; use x86; use x86::shared::dtables::*; use x86::current::irq::IdtEntry; use x86::shared::PrivilegeLevel; use x86::shared::paging::VAddr; extern "C" { static interrupt_handlers: [*const u8; 256]; } pub struct Idt { table: [IdtEntry; 256], } impl Idt { pub const fn new() -> Idt { Idt ...
pub unsafe fn disable() { x86::shared::irq::disable(); }
x86::shared::irq::enable(); }
random_line_split
idt.rs
use core::ptr; use x86; use x86::shared::dtables::*; use x86::current::irq::IdtEntry; use x86::shared::PrivilegeLevel; use x86::shared::paging::VAddr; extern "C" { static interrupt_handlers: [*const u8; 256]; } pub struct Idt { table: [IdtEntry; 256], } impl Idt { pub const fn new() -> Idt
pub fn init(&mut self) { self.setup_gates(); unsafe { x86::shared::dtables::lidt( &DescriptorTablePointer::new_idtp(&self.table) ); } } fn setup_gates(&mut self) { unsafe { for (index, &handler) in interrupt_handlers.ite...
{ Idt { table: [x86::current::irq::IdtEntry::MISSING; 256], } }
identifier_body
parse.rs
use std::iter;
use lex; #[derive(Debug)] pub struct ParseError; #[derive(Debug)] pub enum Node { Number(f64), Operation{operator: char, children: Vec<Node>}, } pub fn parse(input: &str) -> Result<Node, ParseError> { let mut parser = Parser{ tokenizer: lex::Tokenizer::new(input).peekable(), }; parser.par...
random_line_split
parse.rs
use std::iter; use lex; #[derive(Debug)] pub struct ParseError; #[derive(Debug)] pub enum Node { Number(f64), Operation{operator: char, children: Vec<Node>}, } pub fn
(input: &str) -> Result<Node, ParseError> { let mut parser = Parser{ tokenizer: lex::Tokenizer::new(input).peekable(), }; parser.parse_node() } struct Parser<'a> { tokenizer: iter::Peekable<lex::Tokenizer<'a>>, } impl<'a> Parser<'a> { fn parse_node(&mut self) -> Result<Node, ParseError> { ...
parse
identifier_name
test_register_deregister.rs
use mio::*; use mio::tcp::*; use super::localhost; const SERVER: Token = Token(0); const CLIENT: Token = Token(1); struct TestHandler { server: TcpListener, client: TcpStream, state: usize, } impl TestHandler { fn new(srv: TcpListener, cli: TcpStream) -> TestHandler { TestHandler { ...
if events.is_writable() { self.handle_write(event_loop, token, events); } } fn timeout(&mut self, event_loop: &mut EventLoop<TestHandler>, _: usize) { event_loop.shutdown(); } } #[test] pub fn test_register_deregister() { debug!("Starting TEST_REGISTER_DEREGISTER"...
{ self.handle_read(event_loop, token, events); }
conditional_block
test_register_deregister.rs
use mio::*; use mio::tcp::*; use super::localhost; const SERVER: Token = Token(0); const CLIENT: Token = Token(1); struct TestHandler { server: TcpListener, client: TcpStream, state: usize, } impl TestHandler { fn new(srv: TcpListener, cli: TcpStream) -> TestHandler { TestHandler { ...
(&mut self, event_loop: &mut EventLoop<TestHandler>, token: Token, events: EventSet) { assert!(token == CLIENT, "unexpected token {:?}", token); assert!(self.state == 1, "unexpected state {}", self.state); self.state = 2; event_loop.deregister(&self.client).unwrap(); event_loop....
handle_write
identifier_name
test_register_deregister.rs
use mio::*; use mio::tcp::*; use super::localhost; const SERVER: Token = Token(0); const CLIENT: Token = Token(1); struct TestHandler { server: TcpListener, client: TcpStream, state: usize, } impl TestHandler { fn new(srv: TcpListener, cli: TcpStream) -> TestHandler { TestHandler { ...
} _ => panic!("unexpected token"), } } fn handle_write(&mut self, event_loop: &mut EventLoop<TestHandler>, token: Token, events: EventSet) { assert!(token == CLIENT, "unexpected token {:?}", token); assert!(self.state == 1, "unexpected state {}", self.state); ...
} CLIENT => { assert!(self.state == 0, "unexpected state {}", self.state); self.state = 1; event_loop.reregister(&self.client, CLIENT, EventSet::writable(), PollOpt::level()).unwrap();
random_line_split
test_register_deregister.rs
use mio::*; use mio::tcp::*; use super::localhost; const SERVER: Token = Token(0); const CLIENT: Token = Token(1); struct TestHandler { server: TcpListener, client: TcpStream, state: usize, } impl TestHandler { fn new(srv: TcpListener, cli: TcpStream) -> TestHandler { TestHandler { ...
// Register client socket only as writable event_loop.register_opt(&client, CLIENT, EventSet::readable(), PollOpt::level()).unwrap(); let mut handler = TestHandler::new(server, client); // Start the event loop event_loop.run(&mut handler).unwrap(); assert!(handler.state == 2, "unexpected fina...
{ debug!("Starting TEST_REGISTER_DEREGISTER"); let mut event_loop = EventLoop::new().unwrap(); let addr = localhost(); let server = TcpSocket::v4().unwrap(); info!("setting re-use addr"); server.set_reuseaddr(true).unwrap(); server.bind(&addr).unwrap(); let server = server.listen(256...
identifier_body
main.rs
//! This example uses the `glium` library, a high level, safe wrapper for OpenGL. //! //! It is based off the example in the [official tutorial]. //! //! [official tutorial]: https://github.com/glium/glium/tree/master/book use glium::glutin::{ event::{Event, WindowEvent}, event_loop::{ControlFlow, EventLoop}, ...
() { let event_loop = EventLoop::new(); let window_builder = WindowBuilder::new(); let context_builder = ContextBuilder::new(); let display = Display::new(window_builder, context_builder, &event_loop).unwrap(); let vertex1 = Vertex { position: [0.0, 0.0], }; let vertex2 = Vertex { ...
main
identifier_name