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
pluginarray.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::PluginArrayBinding; use dom::bindings::codegen::Bindings::PluginArrayBinding...
PluginArrayBinding::Wrap) } } impl PluginArrayMethods for PluginArray { // https://html.spec.whatwg.org/multipage/#dom-pluginarray-refresh fn Refresh(&self, _reload: bool) { } // https://html.spec.whatwg.org/multipage/#dom-pluginarray-length fn Length(&self) -> u32 {...
pub fn new(global: &GlobalScope) -> DomRoot<PluginArray> { reflect_dom_object(box PluginArray::new_inherited(), global,
random_line_split
pluginarray.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::PluginArrayBinding; use dom::bindings::codegen::Bindings::PluginArrayBinding...
}
{ vec![] }
identifier_body
pluginarray.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::PluginArrayBinding; use dom::bindings::codegen::Bindings::PluginArrayBinding...
(&self) -> Vec<DOMString> { vec![] } }
SupportedPropertyNames
identifier_name
graph.rs
// Copyright (c) 2016 Patrick Burroughs <celti@celti.name>. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0>, or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. // This file may not be copied, modified, or di...
Err(CommandError::ParseArgs(e)) => { println!("Invalid argument: {}", e); usage(argc); process::exit(64) } Err(CommandError::ParseInt(_)) => { println!("An error occurred parsing the input."); ...
rgc); process::exit(0) }
conditional_block
graph.rs
// Copyright (c) 2016 Patrick Burroughs <celti@celti.name>. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0>, or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. // This file may not be copied, modified, or di...
: Vec<String>) -> Result<bool, CommandError> { let arg1 = match argv.get(0) { Some(x) => { x.clone() } None => { return Ok(false) } }; let (call, reverse) = match arg1.as_ref() { "v" => { argv.remove(0); ("vertical", false) } "h" => { argv.remove(0); ("horizontal", false)...
argv
identifier_name
graph.rs
// Copyright (c) 2016 Patrick Burroughs <celti@celti.name>. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0>, or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. // This file may not be copied, modified, or di...
mut argv: Vec<String> = env::args().collect(); let argc: String = argv.remove(0); match _main(argv) { Ok(false) => { usage(argc); process::exit(0) } Err(CommandError::ParseArgs(e)) => { println!("Invalid argument: {}", e...
identifier_body
graph.rs
// Copyright (c) 2016 Patrick Burroughs <celti@celti.name>. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // https://www.apache.org/licenses/LICENSE-2.0>, or the MIT license // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. // This file may not be copied, modified, or di...
extern crate unicode_graph; use std::{env, num, process}; use unicode_graph::{graph, braille}; #[derive(Debug)] enum CommandError { UnknownError, ParseArgs(String), ParseGraph(unicode_graph::ParseGraphError), ParseInt(num::ParseIntError), } impl From<num::ParseIntError> for CommandError { fn from...
// according to those terms.
random_line_split
method-two-trait-defer-resolution-2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { assert_eq!(call_foo_copy(), 1); assert_eq!(call_foo_other(), 2); }
main
identifier_name
method-two-trait-defer-resolution-2.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 call_foo_other() -> isize { let mut x: Vec<_> = Vec::new(); let y = x.foo(); let z: Box<i32> = box 0; x.push(z); y } fn main() { assert_eq!(call_foo_copy(), 1); assert_eq!(call_foo_other(), 2); }
{ let mut x = Vec::new(); let y = x.foo(); x.push(0_i32); y }
identifier_body
method-two-trait-defer-resolution-2.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 call_foo_other() -> isize { let mut x: Vec<_> = Vec::new(); let y = x.foo(); let z: Box<i32> = box 0; x.push(z); y } fn main() { assert_eq!(call_foo_copy(), 1); assert_eq!(call_foo_other(), 2); }
x.push(0_i32); y }
random_line_split
timer.rs
// Copyright 2014 The sdl2-rs Developers. //
// you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WA...
// Licensed under the Apache License, Version 2.0 (the "License");
random_line_split
tokenizer.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
match token { DoctypeToken(Doctype { name, public_id, system_id, force_quirks }) => { let name = opt_str_to_buf(&name); let public_id = opt_str_to_buf(&public_id); let system_id = opt_str_to_buf(&system_id); call!(do_doctype, name.get...
{ match *s { None => LifetimeBuf::null(), Some(ref s) => s.as_lifetime_buf(), } }
identifier_body
tokenizer.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
use core::default::Default; use alloc::boxed::Box; use collections::String; use libc::{c_void, c_int, size_t}; #[repr(C)] pub struct h5e_token_ops { do_doctype: Option<extern "C" fn(user: *mut c_void, name: h5e_buf, public: h5e_buf, system: h5e_buf, force_quirks: c_int)>, do_start_tag: Option<extern "...
use tokenizer::{CommentToken, CharacterTokens, NullCharacterToken}; use tokenizer::{TagToken, StartTag, EndTag, EOFToken, Tokenizer}; use core::mem;
random_line_split
tokenizer.rs
// Copyright 2014 The html5ever Project Developers. See the // COPYRIGHT file at the top-level directory of this distribution. // // 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>,...
(sink: *mut h5e_token_sink) -> h5e_tokenizer_ptr { let tok: Box<Tokenizer<*mut h5e_token_sink>> = box Tokenizer::new(sink, Default::default()); mem::transmute(tok) } #[no_mangle] pub unsafe extern "C" fn h5e_tokenizer_free(tok: h5e_tokenizer_ptr) { let _: Box<Tokenizer<*mut h5e_token_sink>> = mem:...
h5e_tokenizer_new
identifier_name
p091.rs
//! [Problem 91](https://projecteuler.net/problem=91) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use num_integer::Integer; use std::cmp; fn count_right_at_o(x_max: u32, y_max: u32) -> u32 { x_max * y_max } fn c...
(x_max: u32, y_max: u32) -> u32 { count_right_at_o(x_max, y_max) + count_right_at_p(x_max, y_max) * 2 } fn solve() -> String { compute(50, 50).to_string() } common::problem!("14234", solve); #[cfg(test)] mod tests { #[test] fn two() { assert_eq!(4, super::count_right_at_o(2, 2)); asse...
compute
identifier_name
p091.rs
//! [Problem 91](https://projecteuler.net/problem=91) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications, unused_results )] use num_integer::Integer; use std::cmp; fn count_right_at_o(x_max: u32, y_max: u32) -> u32 { x_max * y_max } fn c...
}
{ assert_eq!(4, super::count_right_at_o(2, 2)); assert_eq!(5, super::count_right_at_p(2, 2)); assert_eq!(14, super::compute(2, 2)); }
identifier_body
p091.rs
//! [Problem 91](https://projecteuler.net/problem=91) solver. #![warn( bad_style, unused, unused_extern_crates, unused_import_braces, unused_qualifications,
unused_results )] use num_integer::Integer; use std::cmp; fn count_right_at_o(x_max: u32, y_max: u32) -> u32 { x_max * y_max } fn count_right_at_p(x_max: u32, y_max: u32) -> u32 { let mut cnt = x_max * y_max; // p: (0, y0) q: (xi, y0) => xi: [1, x_max], y0: [0, y_max] for x in 1..(x_max + 1) { ...
random_line_split
benches.rs
#![feature(plugin,test)] #![plugin(power_assert)] extern crate ip2location; extern crate test;
#[bench] fn ip2country (bencher: &mut Bencher) { let ip2location = Ip2Location::open ("/usr/share/ip2location/IP2LOCATION-LITE-DB1.BIN").expect ("!open"); bencher.iter (|| { assert_eq! (ip2location.ip2country ("8.8.8.8").expect ("!ip2country"), Some (*b"US"));})} #[bench] fn location (bencher: &mut Bencher) { ...
use ip2location::Ip2Location; use test::Bencher;
random_line_split
benches.rs
#![feature(plugin,test)] #![plugin(power_assert)] extern crate ip2location; extern crate test; use ip2location::Ip2Location; use test::Bencher; #[bench] fn ip2country (bencher: &mut Bencher) { let ip2location = Ip2Location::open ("/usr/share/ip2location/IP2LOCATION-LITE-DB1.BIN").expect ("!open"); bencher.iter (...
{ let ip2location = Ip2Location::open ("/usr/share/ip2location/IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-SAMPLE.BIN") .expect ("!open"); bencher.iter (|| { let location = ip2location.location ("8.8.8.8") .expect ("!location") .expect ("!8.8.8.8"); power_assert! (location.longitude.round() == -122.0);})}
identifier_body
benches.rs
#![feature(plugin,test)] #![plugin(power_assert)] extern crate ip2location; extern crate test; use ip2location::Ip2Location; use test::Bencher; #[bench] fn
(bencher: &mut Bencher) { let ip2location = Ip2Location::open ("/usr/share/ip2location/IP2LOCATION-LITE-DB1.BIN").expect ("!open"); bencher.iter (|| { assert_eq! (ip2location.ip2country ("8.8.8.8").expect ("!ip2country"), Some (*b"US"));})} #[bench] fn location (bencher: &mut Bencher) { let ip2location = Ip...
ip2country
identifier_name
karma.rs
use rusqlite as rs; use slack_api as slack; use chrono::prelude::{Utc, DateTime}; use std::result::Result; use tokio::sync::mpsc; use crate::bot::parser::karma::KST; use crate::bot::parser::karma; use crate::bot::query::KarmaName; use crate::bot::query::normalize; use crate::bot::query::santizer; use crate::core:...
let mut stmt = conn.prepare("SELECT id FROM chan_metadata WHERE channel =?").unwrap(); let mut rows = stmt.query(rs::params![cid]).unwrap(); if let Ok(Some(row)) = rows.next() { row.get(0).ok() } else { let mut stmt...
{ send_query( sql_tx, Box::new(move |conn: &mut rs::Connection| { let nick_id: i64 = { let mut stmt = conn.prepare("SELECT id FROM nick_metadata WHERE username = ?").unwrap(); let mut rows = stmt.query(rs::params![user_id]).unwrap(); if le...
identifier_body
karma.rs
use rusqlite as rs; use slack_api as slack; use chrono::prelude::{Utc, DateTime}; use std::result::Result; use tokio::sync::mpsc; use crate::bot::parser::karma::KST; use crate::bot::parser::karma; use crate::bot::query::KarmaName; use crate::bot::query::normalize; use crate::bot::query::santizer; use crate::core:...
match (username, user_real_name) { (Some(ud), Some(rn)) => { let _ = add_karma_query( sql_tx, Utc::now(), user_id, KarmaName::new(&ud), ...
random_line_split
karma.rs
use rusqlite as rs; use slack_api as slack; use chrono::prelude::{Utc, DateTime}; use std::result::Result; use tokio::sync::mpsc; use crate::bot::parser::karma::KST; use crate::bot::parser::karma; use crate::bot::query::KarmaName; use crate::bot::query::normalize; use crate::bot::query::santizer; use crate::core:...
( sql_tx: &mut mpsc::Sender<Query>, timestamp: DateTime<Utc>, user_id: String, username: KarmaName, real_name: KarmaName, channel_id: Option<String>, karma: Vec<KST>, ) -> Result<Option<i64>, &'static str> { send_query( sql_tx, Box::new(move |conn: &mut rs::Connection| { ...
add_karma_query
identifier_name
client.rs
use BindClient; use streaming::{Body, Message}; use super::{StreamingPipeline, Frame, Transport}; use super::advanced::{Pipeline, PipelineMessage}; use util::client_proxy::{self, ClientProxy, Receiver}; use futures::{Future, IntoFuture, Poll, Async, Stream}; use futures::sync::oneshot; use tokio_core::reactor::Handle; ...
(&mut self, response: PipelineMessage<Self::Out, Body<Self::BodyOut, Self::Error>, Self::Error>) -> io::Result<()> { if let Some(complete) = self.in_flight.pop_front() { drop(complete.send(response)); } else { return Err(io::Error::new(io::Erro...
dispatch
identifier_name
client.rs
use BindClient; use streaming::{Body, Message}; use super::{StreamingPipeline, Frame, Transport}; use super::advanced::{Pipeline, PipelineMessage}; use util::client_proxy::{self, ClientProxy, Receiver}; use futures::{Future, IntoFuture, Poll, Async, Stream}; use futures::sync::oneshot; use tokio_core::reactor::Handle; ...
Ok(()) } fn poll(&mut self) -> Poll<Option<PipelineMessage<Self::In, Self::Stream, Self::Error>>, io::Error> { trace!("Dispatch::poll"); // Try to get a new request frame match self.requests.poll() { Ok(Async::Ready(Some(Ok((reques...
if let Some(complete) = self.in_flight.pop_front() { drop(complete.send(response)); } else { return Err(io::Error::new(io::ErrorKind::Other, "request / response mismatch")); }
random_line_split
client.rs
use BindClient; use streaming::{Body, Message}; use super::{StreamingPipeline, Frame, Transport}; use super::advanced::{Pipeline, PipelineMessage}; use util::client_proxy::{self, ClientProxy, Receiver}; use futures::{Future, IntoFuture, Poll, Async, Stream}; use futures::sync::oneshot; use tokio_core::reactor::Handle; ...
Ok(()) } fn poll(&mut self) -> Poll<Option<PipelineMessage<Self::In, Self::Stream, Self::Error>>, io::Error> { trace!("Dispatch::poll"); // Try to get a new request frame match self.requests.poll() { Ok(Async::Ready(Some(Ok((reque...
{ return Err(io::Error::new(io::ErrorKind::Other, "request / response mismatch")); }
conditional_block
client.rs
use BindClient; use streaming::{Body, Message}; use super::{StreamingPipeline, Frame, Transport}; use super::advanced::{Pipeline, PipelineMessage}; use util::client_proxy::{self, ClientProxy, Receiver}; use futures::{Future, IntoFuture, Poll, Async, Stream}; use futures::sync::oneshot; use tokio_core::reactor::Handle; ...
fn poll(&mut self) -> Poll<Option<PipelineMessage<Self::In, Self::Stream, Self::Error>>, io::Error> { trace!("Dispatch::poll"); // Try to get a new request frame match self.requests.poll() { Ok(Async::Ready(Some(Ok((request, complete))))) => {...
{ if let Some(complete) = self.in_flight.pop_front() { drop(complete.send(response)); } else { return Err(io::Error::new(io::ErrorKind::Other, "request / response mismatch")); } Ok(()) }
identifier_body
quicksort.rs
// use rand::{thread_rng, Rng}; use std::mem; use super::insertion_sort; /// quicksort partitioning fn partition<T: PartialOrd>(a: &mut [T], lo: usize, hi: usize) -> usize { let mut i = lo; let mut j = hi + 1; loop { loop { i += 1; if a[i] < a[lo] { if i ==...
} } } // Cutoff to insertion sort for ≈ 10 items. const CUTOFF: usize = 10; /// quicksort optimised fn sort<T: PartialOrd>(a: &mut [T], lo: usize, hi: usize) { // # small subarrays improve: if hi <= lo + CUTOFF - 1 { insertion_sort(&mut a[lo.. hi+1]); return ; } // # awa...
{ if a[i] >= a[j] { if a[j] >= a[k] { j } else { if a[i] >= a[k] { k } else { i } } } else { if a[j] >= a[k] { if a[i] >= a[k] { i } else { k ...
identifier_body
quicksort.rs
// use rand::{thread_rng, Rng}; use std::mem; use super::insertion_sort; /// quicksort partitioning fn partition<T: PartialOrd>(a: &mut [T], lo: usize, hi: usize) -> usize { let mut i = lo; let mut j = hi + 1; loop { loop { i += 1; if a[i] < a[lo] { if i ==...
: PartialOrd>(a: &mut [T]) { let n = a.len(); if n > 1 { sort_orig(a, 0, n-1) } } fn sort_3way<T: PartialOrd + Copy>(a: &mut [T], lo: usize, hi: usize) { if hi <= lo { return; } let mut lt = lo; let mut gt = hi; let mut i = lo; // FIXME: this needs Copy let v = ...
ick_sort_orig<T
identifier_name
quicksort.rs
// use rand::{thread_rng, Rng}; use std::mem; use super::insertion_sort; /// quicksort partitioning fn partition<T: PartialOrd>(a: &mut [T], lo: usize, hi: usize) -> usize { let mut i = lo; let mut j = hi + 1; loop { loop { i += 1; if a[i] < a[lo] { if i ==...
} else { break } } loop { j -= 1; if a[lo] < a[j] { if j == lo { break } } else { break } } if i >= j { break; } a.swap(i, j); } ...
{ break }
conditional_block
quicksort.rs
// use rand::{thread_rng, Rng}; use std::mem; use super::insertion_sort; /// quicksort partitioning fn partition<T: PartialOrd>(a: &mut [T], lo: usize, hi: usize) -> usize { let mut i = lo; let mut j = hi + 1; loop { loop { i += 1; if a[i] < a[lo] { if i ==...
} let mut lt = lo; let mut gt = hi; let mut i = lo; // FIXME: this needs Copy let v = a[lo]; while i <= gt { if a[i] < v { a.swap(lt, i); lt += 1; i += 1; } else if a[i] > v { a.swap(i, gt); gt -= 1; } else ...
if hi <= lo { return;
random_line_split
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
, Err(error) => { self.compilation_status.set(ShaderCompilationStatus::Failed); debug!("Shader {} compilation failed: {}", self.id, error); }, } *self.info_log.borrow_mut() = Some(validator.info_log()); // TODO(...
{ debug!("Shader translated: {}", translated_source); // NOTE: At this point we should be pretty sure that the compilation in the paint thread // will succeed. // It could be interesting to retrieve the info log from the paint thread though...
conditional_block
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
(&self, source: DOMString) { *self.source.borrow_mut() = Some(source); } pub fn successfully_compiled(&self) -> bool { self.compilation_status.get() == ShaderCompilationStatus::Succeeded } } impl Drop for WebGLShader { fn drop(&mut self) { assert!(self.attached_counter.get() ==...
set_source
identifier_name
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
self.attached_counter.get() > 0 } pub fn increment_attached_counter(&self) { self.attached_counter.set(self.attached_counter.get() + 1); } pub fn decrement_attached_counter(&self) { assert!(self.attached_counter.get() > 0); self.attached_counter.set(self.attached_counte...
pub fn is_deleted(&self) -> bool { self.is_deleted.get() } pub fn is_attached(&self) -> bool {
random_line_split
webglshader.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/. */ // https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl use angle::hl::{BuiltInResources, Output, Sha...
/// Get the shader source pub fn source(&self) -> Option<DOMString> { self.source.borrow().clone() } /// glShaderSource pub fn set_source(&self, source: DOMString) { *self.source.borrow_mut() = Some(source); } pub fn successfully_compiled(&self) -> bool { self.com...
{ let (sender, receiver) = webgl_channel().unwrap(); self.renderer.send(WebGLCommand::GetShaderParameter(self.id, param_id, sender)).unwrap(); receiver.recv().unwrap() }
identifier_body
issue-19452.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 ...
{ Madoka { age: u32 } } fn main() { let homura = Homura::Madoka; //~^ ERROR expected value, found struct variant `Homura::Madoka` let homura = issue_19452_aux::Homura::Madoka; //~^ ERROR expected value, found struct variant `issue_19452_aux::Homura::Madoka` }
Homura
identifier_name
issue-19452.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 ...
{ let homura = Homura::Madoka; //~^ ERROR expected value, found struct variant `Homura::Madoka` let homura = issue_19452_aux::Homura::Madoka; //~^ ERROR expected value, found struct variant `issue_19452_aux::Homura::Madoka` }
identifier_body
issue-19452.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 ...
// aux-build:issue_19452_aux.rs extern crate issue_19452_aux; enum Homura { Madoka { age: u32 } } fn main() { let homura = Homura::Madoka; //~^ ERROR expected value, found struct variant `Homura::Madoka` let homura = issue_19452_aux::Homura::Madoka; //~^ ERROR expected value, found struct varian...
// except according to those terms.
random_line_split
sine.rs
#![allow(non_snake_case)] #![allow(trivial_numeric_casts)] // FIXME: rust-lang/rfcs#1020 #[macro_use] extern crate lua; extern crate libc; use std::io; use std::io::prelude::*; pub fn repl(L: &mut lua::State) { let mut stdin = io::stdin(); let mut stdout = io::stdout(); let mut stderr = io::stderr(); ...
} } } } fn main() { let mut L = lua::State::new(); L.openlibs(); L.register("sin", my_sin); L.register("cos", my_cos); L.register("tan", my_tan); repl(&mut L); } lua_extern! { unsafe fn my_sin(L: &mut lua::ExternState) -> i32 { let input = L.checknumber(1);...
{ let _ = writeln!(&mut stderr, "error calling 'print' ({})", L.describe(-1)); continue; }
conditional_block
sine.rs
#![allow(non_snake_case)] #![allow(trivial_numeric_casts)] // FIXME: rust-lang/rfcs#1020 #[macro_use] extern crate lua; extern crate libc; use std::io; use std::io::prelude::*; pub fn repl(L: &mut lua::State)
match L.pcall(0, lua::MULTRET, 0) { Ok(_) => (), Err(_) => { match L.tostring(-1) { Some(msg) => { let _ = writeln!(&mut stderr, "{}", msg); } None => { let _ = writeln!(&mut stderr, "(error object is not a string)"); } ...
{ let mut stdin = io::stdin(); let mut stdout = io::stdout(); let mut stderr = io::stderr(); let mut line = String::new(); loop { L.settop(0); // clear the stack let _ = write!(&mut stdout, "> "); let _ = stdout.flush(); line.clear(); if let Err(_) = stdin.rea...
identifier_body
sine.rs
#![allow(non_snake_case)] #![allow(trivial_numeric_casts)] // FIXME: rust-lang/rfcs#1020 #[macro_use] extern crate lua; extern crate libc; use std::io; use std::io::prelude::*; pub fn
(L: &mut lua::State) { let mut stdin = io::stdin(); let mut stdout = io::stdout(); let mut stderr = io::stderr(); let mut line = String::new(); loop { L.settop(0); // clear the stack let _ = write!(&mut stdout, "> "); let _ = stdout.flush(); line.clear(); if l...
repl
identifier_name
sine.rs
#![allow(non_snake_case)] #![allow(trivial_numeric_casts)] // FIXME: rust-lang/rfcs#1020 #[macro_use] extern crate lua; extern crate libc; use std::io; use std::io::prelude::*; pub fn repl(L: &mut lua::State) { let mut stdin = io::stdin(); let mut stdout = io::stdout(); let mut stderr = io::stderr(); ...
} if L.gettop() > 0 { L.getglobal("print"); L.insert(1); let nargs = L.gettop()-1; match L.pcall(nargs, 0, 0) { Ok(_) => (), Err(_) => { let _ = writeln!(&mut stderr, "error calling 'print' ({})", L.descr...
}
random_line_split
unit-like-struct-drop-run.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 s = x.unwrap_err().move::<&'static str>().unwrap(); assert_eq!(s.as_slice(), "This failure should happen.");
random_line_split
unit-like-struct-drop-run.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 ...
; impl Drop for Foo { fn drop(&mut self) { fail!("This failure should happen."); } } pub fn main() { let x = task::try(proc() { let _b = Foo; }); let s = x.unwrap_err().move::<&'static str>().unwrap(); assert_eq!(s.as_slice(), "This failure should happen."); }
Foo
identifier_name
unit-like-struct-drop-run.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ let x = task::try(proc() { let _b = Foo; }); let s = x.unwrap_err().move::<&'static str>().unwrap(); assert_eq!(s.as_slice(), "This failure should happen."); }
identifier_body
happy_numbers.rs
// Implements http://rosettacode.org/wiki/Happy_numbers use std::collections::treemap::TreeSet; #[cfg(not(test))] use std::iter::count; fn digits(mut n: uint) -> Vec<uint> { let mut ds = vec![]; if n == 0 { return vec![0]; } while n > 0 { ds.push(n % 10); n /= 10; } ds....
#[test] fn test_is_happy() { let happys = [1u, 7, 10, 13, 19, 23, 28, 31, 1607, 1663]; let unhappys = [0u, 2, 3, 4, 5, 6, 8, 9, 29, 1662]; assert!(happys.iter().all(|&n| is_happy(n))); assert!(unhappys.iter().all(|&n|!is_happy(n))); }
{ assert_eq!(digits(0), vec![0]); assert_eq!(digits(1), vec![1]); assert_eq!(digits(2), vec![2]); assert_eq!(digits(10), vec![1, 0]); assert_eq!(digits(11), vec![1, 1]); assert_eq!(digits(101), vec![1, 0, 1]); assert_eq!(digits(1000), vec![1, 0, 0, 0]); }
identifier_body
happy_numbers.rs
// Implements http://rosettacode.org/wiki/Happy_numbers use std::collections::treemap::TreeSet; #[cfg(not(test))] use std::iter::count; fn digits(mut n: uint) -> Vec<uint> { let mut ds = vec![]; if n == 0 { return vec![0]; } while n > 0 { ds.push(n % 10); n /= 10; } ds....
() { let happys = [1u, 7, 10, 13, 19, 23, 28, 31, 1607, 1663]; let unhappys = [0u, 2, 3, 4, 5, 6, 8, 9, 29, 1662]; assert!(happys.iter().all(|&n| is_happy(n))); assert!(unhappys.iter().all(|&n|!is_happy(n))); }
test_is_happy
identifier_name
happy_numbers.rs
// Implements http://rosettacode.org/wiki/Happy_numbers use std::collections::treemap::TreeSet; #[cfg(not(test))] use std::iter::count; fn digits(mut n: uint) -> Vec<uint> { let mut ds = vec![]; if n == 0
while n > 0 { ds.push(n % 10); n /= 10; } ds.reverse(); ds } fn is_happy(mut x: uint) -> bool { let mut past = TreeSet::new(); while x!= 1 { // Take the sum of the squares of the digits of x x = digits(x).iter().fold(0, |a, &b| a + b * b); // The number...
{ return vec![0]; }
conditional_block
happy_numbers.rs
// Implements http://rosettacode.org/wiki/Happy_numbers use std::collections::treemap::TreeSet; #[cfg(not(test))] use std::iter::count; fn digits(mut n: uint) -> Vec<uint> { let mut ds = vec![]; if n == 0 { return vec![0]; } while n > 0 { ds.push(n % 10); n /= 10; } ds....
// The number is not happy if there is an endless loop if past.contains(&x) { return false } past.insert(x); } true } #[cfg(not(test))] fn main() { // Print the first 8 happy numbers let v: Vec<uint> = count(1u, 1) .filter(|x| is_happy(*x)) .ta...
random_line_split
astconv_util.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...
{ if let ast::TyPath(None, ref path) = ast_ty.node { let def = match tcx.def_map.borrow().get(&ast_ty.id) { None => { tcx.sess.span_bug(ast_ty.span, &format!("unbound path {}", path.repr(tcx))) } Some(d) => d.full_def() ...
identifier_body
astconv_util.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...
Some(d) => d.full_def() }; if let def::DefPrimTy(nty) = def { Some(prim_ty_to_ty(tcx, &path.segments, nty)) } else { None } } else { None } }
{ tcx.sess.span_bug(ast_ty.span, &format!("unbound path {}", path.repr(tcx))) }
conditional_block
astconv_util.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...
<'tcx>(tcx: &ty::ctxt<'tcx>, segments: &[ast::PathSegment], nty: ast::PrimTy) -> Ty<'tcx> { check_path_args(tcx, segments, NO_TPS | NO_REGIONS); match nty { ast::TyBool => tcx.types.bool, ast::TyChar => tcx.types.ch...
prim_ty_to_ty
identifier_name
issue-17718.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 ...
() { assert_eq!(C1, 1); assert_eq!(C3(), ()); assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); assert_eq!(C4, 2); assert_eq!(*C5, 2); assert_eq!(C6, 3); assert_eq!(S1, 3); assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0); assert_...
main
identifier_name
issue-17718.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() { assert_eq!(C1, 1); assert_eq!(C3(), ()); assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); assert_eq!(C2.fetch_add(1, Ordering::SeqCst), 0); assert_eq!(C4, 2); assert_eq!(*C5, 2); assert_eq!(C6, 3); assert_eq!(S1, 3); assert_eq!(S2.fetch_add(1, Ordering::SeqCst), 0); ...
{}
identifier_body
issue-17718.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 ...
let _a = other::C3; let _a = other::C4; let _a = other::C5; match 1 { other::C1 => {} _ => unreachable!(), } }
random_line_split
overload-index-operator.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 foo = ~"foo"; let bar = ~"bar"; let mut list = AssociationList {pairs: ~[]}; list.push(copy foo, 22); list.push(copy bar, 44); assert!(list[foo] == 22) assert!(list[bar] == 44) assert!(list[foo] == 22) assert!(list[bar] == 44) }
{ for self.pairs.iter().advance |pair| { if pair.key == *index { return copy pair.value; } } fail!("No value found for key: %?", index); }
identifier_body
overload-index-operator.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 ...
} fail!("No value found for key: %?", index); } } pub fn main() { let foo = ~"foo"; let bar = ~"bar"; let mut list = AssociationList {pairs: ~[]}; list.push(copy foo, 22); list.push(copy bar, 44); assert!(list[foo] == 22) assert!(list[bar] == 44) assert!(list[foo...
{ return copy pair.value; }
conditional_block
overload-index-operator.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 ...
(&mut self, key: K, value: V) { self.pairs.push(AssociationPair {key: key, value: value}); } } impl<K:Eq,V:Copy> Index<K,V> for AssociationList<K,V> { fn index(&self, index: &K) -> V { for self.pairs.iter().advance |pair| { if pair.key == *index { return copy pair.va...
push
identifier_name
overload-index-operator.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<K:Eq,V:Copy> Index<K,V> for AssociationList<K,V> { fn index(&self, index: &K) -> V { for self.pairs.iter().advance |pair| { if pair.key == *index { return copy pair.value; } } fail!("No value found for key: %?", index); } } pub fn main() {...
}
random_line_split
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
{ Comment, Text, ProcessingInstruction, } pub trait CharacterDataHelpers<'a> { fn data(self) -> Ref<'a, DOMString>; } impl<'a> CharacterDataHelpers<'a> for JSRef<'a, CharacterData> { #[inline] fn data(self) -> Ref<'a, DOMString> { self.extended_deref().data.borrow() } } #[allow(u...
CharacterDataTypeId
identifier_name
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
// https://dom.spec.whatwg.org/#dom-childnode-before fn Before(self, nodes: Vec<NodeOrString>) -> ErrorResult { NodeCast::from_ref(self).before(nodes) } // https://dom.spec.whatwg.org/#dom-childnode-after fn After(self, nodes: Vec<NodeOrString>) -> ErrorResult { NodeCast::from_ref...
{ let length = self.data.borrow().chars().count() as u32; if offset > length { return Err(IndexSize); } let count = if offset + count > length { length - offset } else { count }; let mut data = self.data.borrow().slice_chars(0, ...
identifier_body
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
; let mut data = self.data.borrow().slice_chars(0, offset as usize).to_owned(); data.push_str(&arg); data.push_str(&self.data.borrow().slice_chars((offset + count) as usize, length as usize)); *self.data.borrow_mut() = data; // FIXME: Once we have `Range`, we should implement ste...
{ count }
conditional_block
characterdata.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/. */ //! DOM bindings for `CharacterData`. use dom::bindings::cell::DOMRefCell; use dom::bindings::codegen::Bindings::...
pub fn new_inherited(id: CharacterDataTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData { CharacterData { node: Node::new_inherited(NodeTypeId::CharacterData(id), document), data: DOMRefCell::new(data), } } } impl<'a> CharacterDataMethods for JSRef<'a,...
impl CharacterData {
random_line_split
text_attributes.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use ffi; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct...
(&self, dest: &TextAttributes) { unsafe { ffi::gtk_text_attributes_copy_values(self.to_glib_none().0, dest.to_glib_none().0); } } } impl Default for TextAttributes { fn default() -> Self { Self::new() } }
copy_values
identifier_name
text_attributes.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use ffi; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct...
} impl Default for TextAttributes { fn default() -> Self { Self::new() } }
{ unsafe { ffi::gtk_text_attributes_copy_values(self.to_glib_none().0, dest.to_glib_none().0); } }
identifier_body
text_attributes.rs
// This file was generated by gir (https://github.com/gtk-rs/gir) // from gir-files (https://github.com/gtk-rs/gir-files) // DO NOT EDIT use ffi; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct...
pub fn new() -> TextAttributes { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gtk_text_attributes_new()) } } pub fn copy(&self) -> Option<TextAttributes> { unsafe { from_glib_full(ffi::gtk_text_attributes_copy(self.to_glib_none().0)...
impl TextAttributes {
random_line_split
main.rs
//! goto :: Flexible Working Directory Shortcuts //! //! Copyright (c) 2016-2019 by William R. Fraser #[macro_use] extern crate serde_derive; use std::collections::btree_map::*; use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; use docopt::Docopt; const CONFIG_FILENAM...
() { let args: Args = Docopt::new(USAGE) .and_then(|d| { d.version(Some(format!("goto {}", env!("CARGO_PKG_VERSION")))) .deserialize() }) .unwrap_or_else(|e| { exit(&format!("{}", e), e.fatal()); }); let shellcmd = args.flag_cmd.as_ref().map(|s|...
main
identifier_name
main.rs
//! goto :: Flexible Working Directory Shortcuts //! //! Copyright (c) 2016-2019 by William R. Fraser #[macro_use] extern crate serde_derive; use std::collections::btree_map::*; use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; use docopt::Docopt; const CONFIG_FILENAM...
if let Some(config) = read_config(home_config_path)? { combine_configs(&mut combined, config); } Ok(combined) } fn exit(msg: &str, fatal: bool) ->! { io::stderr().write_all(msg.as_bytes()).unwrap(); if!msg.ends_with('\n') { io::stderr().write_all(b"\n").unwrap(); } let ex...
{ assert!(cwd.is_absolute()); let mut combined = Configuration::default(); // Accumulate paths by stripping off components until we hit the root. let mut search_paths = Vec::<&Path>::new(); let mut maybe_path = Some(cwd); while let Some(path) = maybe_path { search_paths.push(path); ...
identifier_body
main.rs
//! goto :: Flexible Working Directory Shortcuts //! //! Copyright (c) 2016-2019 by William R. Fraser #[macro_use] extern crate serde_derive; use std::collections::btree_map::*; use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; use docopt::Docopt; const CONFIG_FILENAM...
} } } } /// Read the configuration file at the given path. /// If the file does not exist, returns Ok(None), otherwise if the file cannot be read or processed /// for any reason, returns a message explaining the error. fn read_config(config_path: &Path) -> Result<Option<Configuration>, String> ...
Entry::Occupied(mut combined_context) => { combined_context.get_mut().append(&mut context); }, Entry::Vacant(entry) => { entry.insert(context);
random_line_split
main.rs
//! goto :: Flexible Working Directory Shortcuts //! //! Copyright (c) 2016-2019 by William R. Fraser #[macro_use] extern crate serde_derive; use std::collections::btree_map::*; use std::env; use std::fs::File; use std::io::{self, Read, Write}; use std::path::{Path, PathBuf}; use docopt::Docopt; const CONFIG_FILENAM...
} Ok(config) } /// Combine two configurations. The entries in `overlay` take precedence. fn combine_configs(combined: &mut Configuration, mut overlay: Configuration) { combined.global.append(&mut overlay.global); for (context_path, mut context) in overlay.contexts { match combined.contexts.en...
{ // A top-level entry. Attempt to parse as a path and insert into the global table. let mapped_path: PathBuf = match parse_toml_as_path(&v, relative_to) { Ok(path) => path, Err(msg) => { return Err(format!( "error at {}...
conditional_block
regions-bounded-by-send.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 param_not_ok2<'a>(_: &'a int) { assert_send::<&'a [int]>(); //~ ERROR does not fulfill } // boxes are ok fn box_ok() { assert_send::<Box<int>>(); assert_send::<String>(); assert_send::<Vec<int>>(); } // but not if they own a bad thing fn box_with_region_not_ok<'a>() { assert_send::<Box<&'a ...
{ assert_send::<&'a str>(); //~ ERROR does not fulfill }
identifier_body
regions-bounded-by-send.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 ...
} // objects with insufficient bounds no ok fn object_with_random_bound_not_ok<'a>() { assert_send::<&'a (Dummy+'a)>(); //~^ ERROR not implemented } fn object_with_send_bound_not_ok<'a>() { assert_send::<&'a (Dummy+Send)>(); //~^ ERROR does not fulfill } fn proc_with_lifetime_not_ok<'a>() { asse...
fn box_with_region_not_ok<'a>() { assert_send::<Box<&'a int>>(); //~ ERROR does not fulfill
random_line_split
regions-bounded-by-send.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
<'a>() { assert_send::<||:'a>(); //~^ ERROR not implemented } // unsafe pointers are ok unless they point at unsendable things fn unsafe_ok1<'a>(_: &'a int) { assert_send::<*const int>(); assert_send::<*mut int>(); } fn unsafe_ok2<'a>(_: &'a int) { assert_send::<*const &'a int>(); //~ ERROR does ...
closure_with_lifetime_not_ok
identifier_name
packet.rs
use error::QuicError; use error::Result; use std::io::Cursor; use std::io::Read; use byteorder::{WriteBytesExt, ReadBytesExt, BigEndian}; use header::QuicHeader; use header::ShortHeader; use header::LongHeader; use frames::QuicFrame; bitflags! { pub flags ShortPacketType: u8 { const ONE_BYTE = 0x01...
{ pub header: QuicHeader, pub payload: QuicPayload, } impl QuicPacket { pub fn from_bytes(buf: &[u8]) -> Result<QuicPacket> { let mut reader = Cursor::new(buf); let first_byte = reader.read_uint::<BigEndian>(1)? as u8; if first_byte & 0x80!= 0 { // Long Header let mut ...
QuicPacket
identifier_name
packet.rs
use error::QuicError; use error::Result; use std::io::Cursor; use std::io::Read; use byteorder::{WriteBytesExt, ReadBytesExt, BigEndian}; use header::QuicHeader; use header::ShortHeader; use header::LongHeader; use frames::QuicFrame; bitflags! { pub flags ShortPacketType: u8 { const ONE_BYTE = 0x01, ...
} else { // ShortHeader let packet_type = match ShortPacketType::from_bits(first_byte & 0x1f) { Some(pt) => pt, None => return Err(QuicError::ParseError) }; let mut header_len = 1; let conn_id_bit = first_byte & 0x40 > 0; ...
random_line_split
mod.rs
// Copyright 2015, Christopher Chambers // Distributed under the GNU GPL v3. See COPYING for details. use regex::Regex; use sbbm_asm::assembler::Assembler; use sbbm_asm::commands::{Command, Target, IntoTarget, players}; use sbbm_asm::fab; use sbbm_asm::hw::{Computer, MemoryRegion, MemoryStride}; use sbbm_asm::layout::...
path.push("server"); path } fn input_path() -> PathBuf { let mut p = server_path(); p.push("input"); p } fn output_path() -> PathBuf { let mut p = server_path(); p.push("output"); p } fn capture_path() -> PathBuf { let mut p = server_path(); p.push("capture"); p } pub str...
path.push("..");
random_line_split
mod.rs
// Copyright 2015, Christopher Chambers // Distributed under the GNU GPL v3. See COPYING for details. use regex::Regex; use sbbm_asm::assembler::Assembler; use sbbm_asm::commands::{Command, Target, IntoTarget, players}; use sbbm_asm::fab; use sbbm_asm::hw::{Computer, MemoryRegion, MemoryStride}; use sbbm_asm::layout::...
} fs::remove_file(capture_path()).unwrap(); (res, captured) } pub fn capture<F, T>(&self, f: F) -> (T, String) where F : Fn() -> T { let marker = "54799be5-7239-4e00-bd9f-095ae6ed58a3"; let (result, mut output) = self.capture_until(|s| s.contains(marker), || { ...
{ break; }
conditional_block
mod.rs
// Copyright 2015, Christopher Chambers // Distributed under the GNU GPL v3. See COPYING for details. use regex::Regex; use sbbm_asm::assembler::Assembler; use sbbm_asm::commands::{Command, Target, IntoTarget, players}; use sbbm_asm::fab; use sbbm_asm::hw::{Computer, MemoryRegion, MemoryStride}; use sbbm_asm::layout::...
() { let mut f = OpenOptions::new() .write(true) .append(true) .create(true) .open(input_path()) .unwrap(); computer().write_destroy_script(&mut f).unwrap(); }
destroy_computer
identifier_name
mod.rs
// Copyright 2015, Christopher Chambers // Distributed under the GNU GPL v3. See COPYING for details. use regex::Regex; use sbbm_asm::assembler::Assembler; use sbbm_asm::commands::{Command, Target, IntoTarget, players}; use sbbm_asm::fab; use sbbm_asm::hw::{Computer, MemoryRegion, MemoryStride}; use sbbm_asm::layout::...
fn output_path() -> PathBuf { let mut p = server_path(); p.push("output"); p } fn capture_path() -> PathBuf { let mut p = server_path(); p.push("capture"); p } pub struct Server { _guard: MutexGuard<'static, ()>, } impl Server { pub fn new() -> Server { let guard = SERVER_MU...
{ let mut p = server_path(); p.push("input"); p }
identifier_body
percent_encoding.rs
// Copyright 2013-2014 Simon Sapin. // // 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 accordi...
}; /// Percent-encode the given bytes, and push the result to `output`. /// /// The pushed strings are within the ASCII range. #[inline] pub fn percent_encode_to(input: &[u8], encode_set: EncodeSet, output: &mut String) { for &byte in input { output.push_str(encode_set.map[byte as usize]) } } /// Pe...
pub static USERNAME_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::USERNAME }; /// This encode set is used in `application/x-www-form-urlencoded` serialization. pub static FORM_URLENCODED_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::FORM_URLENCODED,
random_line_split
percent_encoding.rs
// Copyright 2013-2014 Simon Sapin. // // 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 accordi...
tch byte { b'0' ... b'9' => Some(byte - b'0'), // 0..9 b'A' ... b'F' => Some(byte + 10 - b'A'), // A..F b'a' ... b'f' => Some(byte + 10 - b'a'), // a..f _ => None } }
identifier_body
percent_encoding.rs
// Copyright 2013-2014 Simon Sapin. // // 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 accordi...
map: &'static [&'static str; 256], } /// This encode set is used for fragment identifier and non-relative scheme data. pub static SIMPLE_ENCODE_SET: EncodeSet = EncodeSet { map: &encode_sets::SIMPLE }; /// This encode set is used in the URL parser for query strings. pub static QUERY_ENCODE_SET: EncodeSet = Encod...
codeSet {
identifier_name
serviceworkercontainer.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::ServiceWorkerContainerBinding::RegistrationOptions; use dom::bindings::codeg...
let &USVString(ref inner_scope) = scope; match self.global().r().api_base_url().join(inner_scope) { Ok(url) => url, Err(_) => return Err(Error::Type("Invalid scope URL".to_owned())) } }, None => script_url.jo...
{ let USVString(ref script_url) = script_url; // Step 3-4 let script_url = match self.global().r().api_base_url().join(script_url) { Ok(url) => url, Err(_) => return Err(Error::Type("Invalid script URL".to_owned())) }; // Step 5 match script_url.sc...
identifier_body
serviceworkercontainer.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::ServiceWorkerContainerBinding::RegistrationOptions; use dom::bindings::codeg...
let scope_str = scope.as_str().to_owned(); let worker_registration = ServiceWorkerRegistration::new(self.global().r(), script_url, scope_str.clone(), ...
{ return Err(Error::Type("Scope URL contains forbidden characters".to_owned())); }
conditional_block
serviceworkercontainer.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::ServiceWorkerContainerBinding::RegistrationOptions; use dom::bindings::codeg...
() -> ServiceWorkerContainer { ServiceWorkerContainer { eventtarget: EventTarget::new_inherited(), controller: Default::default(), } } pub fn new(global: GlobalRef) -> Root<ServiceWorkerContainer> { reflect_dom_object(box ServiceWorkerContainer::new_inherited(), ...
new_inherited
identifier_name
serviceworkercontainer.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::ServiceWorkerContainerBinding::RegistrationOptions; use dom::bindings::codeg...
use dom::eventtarget::EventTarget; use dom::serviceworker::ServiceWorker; use dom::serviceworkerregistration::ServiceWorkerRegistration; use script_thread::ScriptThread; use std::ascii::AsciiExt; use std::default::Default; #[dom_struct] pub struct ServiceWorkerContainer { eventtarget: EventTarget, controller: ...
use dom::bindings::reflector::{Reflectable, reflect_dom_object}; use dom::bindings::str::USVString;
random_line_split
macro-stmt.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...
() { macro_rules! mylet { ($x:ident, $val:expr) => ( let $x = $val; ) } mylet!(y, 8i*2); assert_eq!(y, 16i); myfn!(mult, (a,b), { a*b } ); assert_eq!(mult(2, add(4,4)), 16); macro_rules! actually_an_expr_macro { () => ( 16i ) } assert_eq!({ a...
main
identifier_name
macro-stmt.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...
}
{ macro_rules! mylet { ($x:ident, $val:expr) => ( let $x = $val; ) } mylet!(y, 8i*2); assert_eq!(y, 16i); myfn!(mult, (a,b), { a*b } ); assert_eq!(mult(2, add(4,4)), 16); macro_rules! actually_an_expr_macro { () => ( 16i ) } assert_eq!({ actu...
identifier_body
macro-stmt.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...
}
random_line_split
issue-52050.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 main() { }
impl IntoPyDictPointer for () //~ ERROR conflicting implementations {
random_line_split
issue-52050.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 ...
{ } impl Iterator for Foo { type Item = (); fn next(&mut self) -> Option<()> { None } } impl IntoPyDictPointer for Foo { } impl<I> IntoPyDictPointer for I where I: Iterator, { } impl IntoPyDictPointer for () //~ ERROR conflicting implementations { } fn main() { }
Foo
identifier_name
camera.rs
use glutin::Window; use cgmath::{Point2, Vector2, EuclideanSpace}; #[derive(Debug, Clone)] pub struct Camera { pub position: Point2<f32>, pub size: Vector2<f32>, pub translate: Vector2<f32>, pub scale: Vector2<f32>, } impl Camera { pub fn new(position: Point2<f32>, size: Vector2<f32>, window: &Win...
pub fn window_vector_to_gl(v: Vector2<i32>, window: &Window) -> Vector2<f32> { let (w, h) = window.get_inner_size_pixels().unwrap(); Vector2 { x: (v.x as f32 / w as f32), y: -(v.y as f32 / h as f32), } } pub fn window_point_to_world(&self, p: Point2<i32>, ...
{ let (w, h) = window.get_inner_size_pixels().unwrap(); Point2 { x: (p.x as f32 / w as f32) * 2.0 - 1.0, y: 1.0 - (p.y as f32 / h as f32) * 2.0, } }
identifier_body
camera.rs
use glutin::Window; use cgmath::{Point2, Vector2, EuclideanSpace}; #[derive(Debug, Clone)] pub struct
{ pub position: Point2<f32>, pub size: Vector2<f32>, pub translate: Vector2<f32>, pub scale: Vector2<f32>, } impl Camera { pub fn new(position: Point2<f32>, size: Vector2<f32>, window: &Window) -> Self { let mut camera = Camera { position: position, size: size, ...
Camera
identifier_name
camera.rs
use glutin::Window; use cgmath::{Point2, Vector2, EuclideanSpace}; #[derive(Debug, Clone)] pub struct Camera { pub position: Point2<f32>, pub size: Vector2<f32>, pub translate: Vector2<f32>, pub scale: Vector2<f32>, } impl Camera { pub fn new(position: Point2<f32>, size: Vector2<f32>, window: &Win...
let camera_aspect_ratio = self.size.x / self.size.y; let aspect_ratio = window_aspect_ratio / camera_aspect_ratio; let size = if aspect_ratio >= 1. { Vector2::new(self.size.x * aspect_ratio, self.size.y) } else { Vector2::new(self.size.x, self.size.y / aspect_rat...
random_line_split
camera.rs
use glutin::Window; use cgmath::{Point2, Vector2, EuclideanSpace}; #[derive(Debug, Clone)] pub struct Camera { pub position: Point2<f32>, pub size: Vector2<f32>, pub translate: Vector2<f32>, pub scale: Vector2<f32>, } impl Camera { pub fn new(position: Point2<f32>, size: Vector2<f32>, window: &Win...
else { Vector2::new(self.size.x, self.size.y / aspect_ratio) }; self.translate = -self.position.to_vec(); self.scale = Vector2::new(2. / size.x, 2. / size.y); } pub fn window_point_to_gl(p: Point2<i32>, window: &Window) -> Point2<f32> { let (w, h) = window.get_inne...
{ Vector2::new(self.size.x * aspect_ratio, self.size.y) }
conditional_block
expr-block-generic.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 test_bool() { fn compare_bool(b1: bool, b2: bool) -> bool { return b1 == b2; } test_generic::<bool, _>(true, compare_bool); } #[derive(Clone)] struct Pair { a: int, b: int, } fn test_rec() { fn compare_rec(t1: Pair, t2: Pair) -> bool { t1.a == t2.a && t1.b == t2.b } test_gener...
{ let actual: T = { expected.clone() }; assert!(eq(expected, actual)); }
identifier_body
expr-block-generic.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...
} pub fn main() { test_bool(); test_rec(); }
} test_generic::<Pair, _>(Pair {a: 1, b: 2}, compare_rec);
random_line_split
expr-block-generic.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...
{ a: int, b: int, } fn test_rec() { fn compare_rec(t1: Pair, t2: Pair) -> bool { t1.a == t2.a && t1.b == t2.b } test_generic::<Pair, _>(Pair {a: 1, b: 2}, compare_rec); } pub fn main() { test_bool(); test_rec(); }
Pair
identifier_name
polygon.rs
//! Draw polygon use types::Color; use {types, triangulation, Graphics, DrawState}; use math::{Matrix2d, Scalar}; /// A polygon #[derive(Copy, Clone)] pub struct Polygon { /// The color of the polygon pub color: Color, } impl Polygon { /// Creates new polygon pub fn new(color: Color) -> Polygon { ...
g.tri_list(draw_state, &self.color, |f| { triangulation::with_lerp_polygons_tri_list(transform, polygons, tween_factor, |vertices| f(v...
{ return; }
conditional_block
polygon.rs
//! Draw polygon use types::Color; use {types, triangulation, Graphics, DrawState}; use math::{Matrix2d, Scalar}; /// A polygon #[derive(Copy, Clone)] pub struct Polygon { /// The color of the polygon pub color: Color, } impl Polygon { /// Creates new polygon pub fn new(color: Color) -> Polygon { ...
} #[cfg(test)] mod test { use super::*; #[test] fn test_polygon() { let _polygon = Polygon::new([1.0; 4]).color([0.0; 4]); } }
{ if self.color[3] == 0.0 { return; } g.tri_list(draw_state, &self.color, |f| { triangulation::with_lerp_polygons_tri_list(transform, polygons, tween_factor, ...
identifier_body