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 |
|---|---|---|---|---|
formdata.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::utils::{Reflectable, Reflector, reflect_dom_object};
use dom::bindings::error::{Fallible};
use ... | use dom::blob::Blob;
use dom::htmlformelement::HTMLFormElement;
use dom::window::Window;
use servo_util::str::DOMString;
use collections::hashmap::HashMap;
#[deriving(Encodable)]
pub enum FormDatum {
StringData(DOMString),
BlobData { blob: JS<Blob>, name: DOMString }
}
#[deriving(Encodable)]
pub struct FormD... | random_line_split | |
events.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... | window.set_close_polling(true);
window.set_refresh_polling(true);
window.set_focus_polling(true);
window.set_iconify_polling(true);
window.set_framebuffer_size_polling(true);
window.set_key_polling(true);
window.set_char_polling(true);
window.set_char_mods_polling(true);
window.set_m... | {
let mut glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
glfw.window_hint(glfw::WindowHint::Resizable(true));
let (mut window, events) = glfw
.create_window(
800,
600,
"Hello, I am a window.",
glfw::WindowMode::Windowed,
)
.expect(... | identifier_body |
events.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... | let (window_width, window_height) = window.get_size();
window.set_size(window_width + 1, window_height);
window.set_size(window_width, window_height);
}
_ => {}
}
}
glfw::WindowEvent::FileDrop(paths) ... | // Resize should cause the window to "refresh" | random_line_split |
events.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... | (window: &mut glfw::Window, (time, event): (f64, glfw::WindowEvent)) {
match event {
glfw::WindowEvent::Pos(x, y) => {
window.set_title(&format!("Time: {:?}, Window pos: ({:?}, {:?})", time, x, y))
}
glfw::WindowEvent::Size(w, h) => window.set_title(&format!(
"Time: {... | handle_window_event | identifier_name |
issue-23302.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 ... | () { }
| main | identifier_name |
issue-23302.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 ... | enum Y {
A = Y::B as isize, //~ ERROR E0265
B,
}
fn main() { } |
// Since `Y::B` here defaults to `Y::A+1`, this is also a
// recursive definition. | random_line_split |
issue-23302.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 ... | { } | identifier_body | |
scale_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... |
}
| {
unsafe {
gtk::Adjustment::wrap_pointer(ffi::gtk_scale_button_get_adjustment(GTK_SCALEBUTTON(self.unwrap_widget())))
}
} | identifier_body |
scale_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | }
} |
fn get_adjustment(&self) -> gtk::Adjustment {
unsafe {
gtk::Adjustment::wrap_pointer(ffi::gtk_scale_button_get_adjustment(GTK_SCALEBUTTON(self.unwrap_widget())))
} | random_line_split |
scale_button.rs | // This file is part of rgtk.
//
// rgtk is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// rgtk is distributed in the hop... | (&mut self, value: f64) -> () {
unsafe {
ffi::gtk_scale_button_set_value(GTK_SCALEBUTTON(self.unwrap_widget()), value as c_double);
}
}
fn get_value(&self) -> f64 {
unsafe {
ffi::gtk_scale_button_get_value(GTK_SCALEBUTTON(self.unwrap_widget())) as f64
}
... | set_value | identifier_name |
mod.rs | use std::default::Default;
use std::str::FromStr;
use std::string::ToString;
mod tag;
pub use self::tag::Tag;
#[derive(Debug)]
pub struct Playlist {
tags: Vec<Tag>
}
impl Default for Playlist {
fn default() -> Playlist {
let mut tags: Vec<Tag> = Vec::new();
tags.push(Tag::M3U);
tags.... | }
impl FromStr for Playlist {
type Err = ();
fn from_str(s: &str) -> Result<Playlist, ()> {
let mut lines: Vec<&str> = s.split("#").collect();
lines.remove(0);
let mut tags: Vec<Tag> = Vec::new();
for line in lines.iter(){
match Tag::from_str(line.trim()) {
... | random_line_split | |
mod.rs |
use std::default::Default;
use std::str::FromStr;
use std::string::ToString;
mod tag;
pub use self::tag::Tag;
#[derive(Debug)]
pub struct Playlist {
tags: Vec<Tag>
}
impl Default for Playlist {
fn default() -> Playlist {
let mut tags: Vec<Tag> = Vec::new();
tags.push(Tag::M3U);
tags... | (&self) -> String {
self.tags.iter().map(|tag: &Tag| -> String {
tag.to_string()
}).collect::<Vec<String>>().join("\n")
}
}
impl FromStr for Playlist {
type Err = ();
fn from_str(s: &str) -> Result<Playlist, ()> {
let mut lines: Vec<&str> = s.split("#").collect();
... | to_string | identifier_name |
mod.rs |
use std::default::Default;
use std::str::FromStr;
use std::string::ToString;
mod tag;
pub use self::tag::Tag;
#[derive(Debug)]
pub struct Playlist {
tags: Vec<Tag>
}
impl Default for Playlist {
fn default() -> Playlist {
let mut tags: Vec<Tag> = Vec::new();
tags.push(Tag::M3U);
tags... |
}
| {
self.tags.as_slice()
} | identifier_body |
mod.rs |
use std::default::Default;
use std::str::FromStr;
use std::string::ToString;
mod tag;
pub use self::tag::Tag;
#[derive(Debug)]
pub struct Playlist {
tags: Vec<Tag>
}
impl Default for Playlist {
fn default() -> Playlist {
let mut tags: Vec<Tag> = Vec::new();
tags.push(Tag::M3U);
tags... |
}
}
impl Playlist {
pub fn new () -> Playlist {
let tags: Vec<Tag> = Vec::new();
Playlist{tags: tags}
}
pub fn append(&mut self, tag: Tag) {
self.tags.push(tag);
}
pub fn tags(&self) -> &[Tag] {
self.tags.as_slice()
}
}
| {
Ok(Playlist{tags: tags})
} | conditional_block |
testutil.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashSet;
use std::str::FromStr;
use quickcheck::Arbitrary;
use quickcheck::Gen;
use crate::hgid::HgId;
use crate::k... | }
let mut buffer = String::new();
for _i in 0..HgId::hex_len() - hex.len() {
buffer.push('0');
}
buffer.push_str(hex);
HgId::from_str(&buffer).unwrap()
}
pub fn key(path: &str, hexnode: &str) -> Key {
Key::new(repo_path_buf(path), hgid(hexnode))
}
/// The null hgid id is special an... | panic!("hgid 0 is special, use HgId::null_id() to build"); | random_line_split |
testutil.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashSet;
use std::str::FromStr;
use quickcheck::Arbitrary;
use quickcheck::Gen;
use crate::hgid::HgId;
use crate::k... |
pub fn repo_path_buf(s: &str) -> RepoPathBuf {
if s == "" {
panic!("the empty repo path is special, use RepoPathBuf::new() to build");
}
RepoPathBuf::from_string(s.to_owned()).unwrap()
}
pub fn path_component(s: &str) -> &PathComponent {
PathComponent::from_str(s).unwrap()
}
pub fn path_comp... | {
if s == "" {
panic!("the empty repo path is special, use RepoPath::empty() to build");
}
RepoPath::from_str(s).unwrap()
} | identifier_body |
testutil.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashSet;
use std::str::FromStr;
use quickcheck::Arbitrary;
use quickcheck::Gen;
use crate::hgid::HgId;
use crate::k... |
if hex == "0" {
panic!("hgid 0 is special, use HgId::null_id() to build");
}
let mut buffer = String::new();
for _i in 0..HgId::hex_len() - hex.len() {
buffer.push('0');
}
buffer.push_str(hex);
HgId::from_str(&buffer).unwrap()
}
pub fn key(path: &str, hexnode: &str) -> Key ... | {
panic!("invalid length for hex hgid: {}", hex);
} | conditional_block |
testutil.rs | /*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashSet;
use std::str::FromStr;
use quickcheck::Arbitrary;
use quickcheck::Gen;
use crate::hgid::HgId;
use crate::k... | () {
let mut qc_gen = Gen::new(10);
let count = 10000;
let paths = generate_repo_paths(count, &mut qc_gen);
assert_eq!(paths.len(), count);
}
}
| test_generate_repo_paths | identifier_name |
dtstats.rs | use std::io::Result;
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
use std::time::Duration;
extern crate dtlib;
fn main() {
let log_result = parse_log(dtlib::constants::LOG_FILE);
if!log_result.is_ok() {
println!("Could not load log.");
}
else {
let log = log_resul... |
return Box::new(it) as LogIterator;
}
);
} | random_line_split | |
dtstats.rs |
use std::io::Result;
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
use std::time::Duration;
extern crate dtlib;
fn main() {
let log_result = parse_log(dtlib::constants::LOG_FILE);
if!log_result.is_ok() {
println!("Could not load log.");
}
else {
let log = log_resu... | (path : &str) -> Result<LogIterator> {
let file = File::open(path);
return file.map(
|f| {
let buf_file = BufReader::new(f);
let it = buf_file
.lines()
.filter(|line| line.is_ok())
.map(|line| line.unwrap())
.map(|line... | parse_log | identifier_name |
dtstats.rs |
use std::io::Result;
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
use std::time::Duration;
extern crate dtlib;
fn main() {
let log_result = parse_log(dtlib::constants::LOG_FILE);
if!log_result.is_ok() |
else {
let log = log_result.unwrap();
let stats_opt = calc_stats(log);
if!stats_opt.is_some() {
println!("Could not calculate stats.");
}
else {
let stats = stats_opt.unwrap();
print!(
" == DT Stats == \n\
... | {
println!("Could not load log.");
} | conditional_block |
dtstats.rs |
use std::io::Result;
use std::io::BufReader;
use std::io::BufRead;
use std::fs::File;
use std::time::Duration;
extern crate dtlib;
fn main() | \n\
Sectors written: {}\n\
GB written: {}\n\
\n\
Uptime (h): {}\n\
Uptime (d): {}\n\
Uptime (y): {}\n\
\n\
GB/h: {}\n\
GB/d: {}\n\
GB... | {
let log_result = parse_log(dtlib::constants::LOG_FILE);
if !log_result.is_ok() {
println!("Could not load log.");
}
else {
let log = log_result.unwrap();
let stats_opt = calc_stats(log);
if !stats_opt.is_some() {
println!("Could not calculate stats.");
... | identifier_body |
day12.rs | extern crate serde_json;
use std::ops::Add;
use self::serde_json::value::Value;
pub fn json_sum(value: &Value) -> i64 {
match *value {
Value::I64(n) => n,
Value::U64(n) => n as i64,
Value::Array(ref vec) => vec.iter().map(json_sum).fold(0, Add::add),
Value::Object(ref o) => o.value... | #[cfg(test)]
mod tests {
use super::{json_sum_str, json_sum_unred_str};
#[test]
fn test_json_sum() {
assert_eq!(json_sum_str("[1,2,3]"), 6);
assert_eq!(json_sum_str("{\"a\":2,\"b\":4}"), 6);
assert_eq!(json_sum_str("[[[3]]]"), 3);
assert_eq!(json_sum_str("{\"a\":{\"b\":4},\"... | println!("Part 1: {}", json_sum(&json));
println!("Part 2: {}", json_sum_unred(&json));
}
| random_line_split |
day12.rs | extern crate serde_json;
use std::ops::Add;
use self::serde_json::value::Value;
pub fn json_sum(value: &Value) -> i64 {
match *value {
Value::I64(n) => n,
Value::U64(n) => n as i64,
Value::Array(ref vec) => vec.iter().map(json_sum).fold(0, Add::add),
Value::Object(ref o) => o.value... |
}
_ => 0,
}
}
pub fn json_sum_unred_str(json: &str) -> i64 {
match serde_json::from_str(json) {
Ok(val) => json_sum_unred(&val),
Err(_) => 0,
}
}
pub fn process_file(path: &str) {
use std::fs::File;
use std::io::prelude::*;
let mut file = File::open(path).unwra... | {
o.values().map(json_sum_unred).fold(0, Add::add)
} | conditional_block |
day12.rs | extern crate serde_json;
use std::ops::Add;
use self::serde_json::value::Value;
pub fn json_sum(value: &Value) -> i64 {
match *value {
Value::I64(n) => n,
Value::U64(n) => n as i64,
Value::Array(ref vec) => vec.iter().map(json_sum).fold(0, Add::add),
Value::Object(ref o) => o.value... | (path: &str) {
use std::fs::File;
use std::io::prelude::*;
let mut file = File::open(path).unwrap();
let mut string = String::new();
file.read_to_string(&mut string).unwrap();
let json = serde_json::from_str(&string).unwrap();
println!("Part 1: {}", json_sum(&json));
println!("Part 2: {}... | process_file | identifier_name |
day12.rs | extern crate serde_json;
use std::ops::Add;
use self::serde_json::value::Value;
pub fn json_sum(value: &Value) -> i64 {
match *value {
Value::I64(n) => n,
Value::U64(n) => n as i64,
Value::Array(ref vec) => vec.iter().map(json_sum).fold(0, Add::add),
Value::Object(ref o) => o.value... |
pub fn process_file(path: &str) {
use std::fs::File;
use std::io::prelude::*;
let mut file = File::open(path).unwrap();
let mut string = String::new();
file.read_to_string(&mut string).unwrap();
let json = serde_json::from_str(&string).unwrap();
println!("Part 1: {}", json_sum(&json));
... | {
match serde_json::from_str(json) {
Ok(val) => json_sum_unred(&val),
Err(_) => 0,
}
} | identifier_body |
lib.rs | //! A library for encoding/decoding Apple Icon Image (.icns) files.
//!
//! # ICNS concepts
//!
//! To understand this library, it helps to be familiar with the structure of
//! an ICNS file; this section will give a high-level overview, or see
//! [Wikipedia](https://en.wikipedia.org/wiki/Apple_Icon_Image_format) for ... |
#[cfg(feature = "pngio")]
extern crate png;
#[cfg(feature = "pngio")]
mod pngio;
mod element;
pub use self::element::IconElement;
mod family;
pub use self::family::IconFamily;
mod icontype;
pub use self::icontype::{Encoding, IconType, OSType};
mod image;
pub use self::image::{Image, PixelFormat}; | #![warn(missing_docs)]
extern crate byteorder; | random_line_split |
frag.rs | //! API for blowing strings into fragments and putting them back together.
use regex::Regex;
use eval::{self, Error, Value};
use eval::api::conv::str_;
use eval::value::{ArrayRepr, StringRepr};
lazy_static!{
static ref WORD_SEP: Regex = Regex::new(r"\s+").unwrap();
static ref LINE_SEP: Regex = Regex::new("\... | else {
// TODO: include the error message of the offending element's conversion
return Err(Error::new(&format!(
"join() failed to stringify {} element(s) of the input array",
error_count)));
}
}
Err(Error::new(&format!(
"join() expects a ... | {
return Ok(Value::String(strings.join(&d)));
} | conditional_block |
frag.rs | //! API for blowing strings into fragments and putting them back together.
use regex::Regex;
|
lazy_static!{
static ref WORD_SEP: Regex = Regex::new(r"\s+").unwrap();
static ref LINE_SEP: Regex = Regex::new("\r?\n").unwrap();
}
/// Join an array of values into a single delimited string.
pub fn join(delim: Value, array: Value) -> eval::Result {
let delim_type = delim.typename();
let array_type... | use eval::{self, Error, Value};
use eval::api::conv::str_;
use eval::value::{ArrayRepr, StringRepr}; | random_line_split |
frag.rs | //! API for blowing strings into fragments and putting them back together.
use regex::Regex;
use eval::{self, Error, Value};
use eval::api::conv::str_;
use eval::value::{ArrayRepr, StringRepr};
lazy_static!{
static ref WORD_SEP: Regex = Regex::new(r"\s+").unwrap();
static ref LINE_SEP: Regex = Regex::new("\... | (delim: Value, array: Value) -> eval::Result {
let delim_type = delim.typename();
let array_type = array.typename();
if let (Value::String(d), Value::Array(a)) = (delim, array) {
let elem_count = a.len();
let strings: Vec<_> = a.into_iter()
.map(str_).filter(Result::is_ok)
... | join | identifier_name |
frag.rs | //! API for blowing strings into fragments and putting them back together.
use regex::Regex;
use eval::{self, Error, Value};
use eval::api::conv::str_;
use eval::value::{ArrayRepr, StringRepr};
lazy_static!{
static ref WORD_SEP: Regex = Regex::new(r"\s+").unwrap();
static ref LINE_SEP: Regex = Regex::new("\... |
// Utility functions
#[inline]
fn do_regex_split(delim: &Regex, string: &str) -> ArrayRepr {
delim.split(string).map(StringRepr::from).map(Value::String).collect()
}
| {
eval1!((string: &String) -> Array { do_regex_split(&LINE_SEP, string) });
mismatch!("lines"; ("string") => (string))
} | identifier_body |
app.rs | use gtk;
use gdk;
use gio;
use gtk::prelude::*;
use gio::prelude::*;
use std::cell::RefCell;
use std::sync::mpsc::Receiver;
use {NAME, TAGLINE};
use static_resources;
use preferences;
use headerbar;
use sentinel_api::youtube;
use views::trending;
// Define thread local storage keys.
thread_local! {
pub static V... | )>> = RefCell::new(None);
#[allow(unknown_lints, type_complexity)]
pub static THUMBNAILS: RefCell<Option<(
Vec<gtk::Image>,
Receiver<Option<String>>,
)>> = RefCell::new(None);
}
pub fn run_app() -> Result<(), String> {
let application = match gtk::Application::new(
Some("com... | Receiver<Option<Vec<youtube::Video>>>, | random_line_split |
app.rs | use gtk;
use gdk;
use gio;
use gtk::prelude::*;
use gio::prelude::*;
use std::cell::RefCell;
use std::sync::mpsc::Receiver;
use {NAME, TAGLINE};
use static_resources;
use preferences;
use headerbar;
use sentinel_api::youtube;
use views::trending;
// Define thread local storage keys.
thread_local! {
pub static V... | });
let headerbar = headerbar::get_headerbar(&stack, &revealer, &viewport);
win.add(&vbox);
win.set_title(NAME);
win.set_wmclass(NAME, NAME);
win.set_titlebar(&headerbar);
win.show_all();
win.activate();
}
| {
let builder = gtk::Builder::new_from_resource("/com/github/kil0meters/sentinel/gtk/interface.ui");
let win = gtk::ApplicationWindow::new(app);
win.set_default_size(732, 500);
win.set_gravity(gdk::Gravity::Center);
let vbox: gtk::Box = builder.get_object("vbox").unwrap();
let revealer: gtk::R... | identifier_body |
app.rs | use gtk;
use gdk;
use gio;
use gtk::prelude::*;
use gio::prelude::*;
use std::cell::RefCell;
use std::sync::mpsc::Receiver;
use {NAME, TAGLINE};
use static_resources;
use preferences;
use headerbar;
use sentinel_api::youtube;
use views::trending;
// Define thread local storage keys.
thread_local! {
pub static V... | () -> Result<(), String> {
let application = match gtk::Application::new(
Some("com.github.kil0meters.sentinel"),
gio::ApplicationFlags::empty(),
) {
Ok(app) => {
app.connect_activate(move |app| { build_ui(app); });
app
}
Err(e) => {
re... | run_app | identifier_name |
associated-type-projection-from-multiple-supertraits.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 dent<C:BoxCar>(c: C, color: C::Color) {
//~^ ERROR ambiguous associated type `Color` in bounds of `C`
//~| NOTE could derive from `Vehicle`
//~| NOTE could derive from `Box`
}
fn dent_object<COLOR>(c: BoxCar<Color=COLOR>) {
//~^ ERROR ambiguous associated type
}
fn paint<C:BoxCar>(c: C, d: C::Color... | pub trait BoxCar : Box + Vehicle {
}
| random_line_split |
associated-type-projection-from-multiple-supertraits.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() { }
| {
//~^ ERROR ambiguous associated type `Color` in bounds of `C`
//~| NOTE could derive from `Vehicle`
//~| NOTE could derive from `Box`
} | identifier_body |
associated-type-projection-from-multiple-supertraits.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 ... | <COLOR>(c: BoxCar<Color=COLOR>) {
//~^ ERROR ambiguous associated type
}
fn paint<C:BoxCar>(c: C, d: C::Color) {
//~^ ERROR ambiguous associated type `Color` in bounds of `C`
//~| NOTE could derive from `Vehicle`
//~| NOTE could derive from `Box`
}
pub fn main() { }
| dent_object | identifier_name |
issue-3979-generics.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 ... | { x: isize, y: isize }
impl Positioned<isize> for Point {
fn SetX(&mut self, x: isize) {
self.x = x;
}
fn X(&self) -> isize {
self.x
}
}
impl Movable<isize> for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
p.translate(3);
assert_eq!(p.X(), 4);
}
| Point | identifier_name |
issue-3979-generics.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 ... | trait Positioned<S> {
fn SetX(&mut self, S);
fn X(&self) -> S;
}
trait Movable<S: Add<Output=S>>: Positioned<S> {
fn translate(&mut self, dx: S) {
let x = self.X() + dx;
self.SetX(x);
}
}
struct Point { x: isize, y: isize }
impl Positioned<isize> for Point {
fn SetX(&mut self, x: isize) {
... | // pretty-expanded FIXME #23616
use std::ops::Add;
| random_line_split |
issue-3979-generics.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 Movable<isize> for Point {}
pub fn main() {
let mut p = Point{ x: 1, y: 2};
p.translate(3);
assert_eq!(p.X(), 4);
}
| {
self.x
} | identifier_body |
assoc-type.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () { }
| main | identifier_name |
assoc-type.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.
// | // option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we do not yet support elision in associated types, even
// when there is just one name we could take from the impl header.
#![allow(warnings)]
trait MyTrait {
type Output;
}
impl MyTrait for &i32 {
... | // 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 | random_line_split |
assoc-type.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 ... | { } | identifier_body | |
build.rs | use flapigen::{CppConfig, CppOptional, CppStrView, CppVariant, LanguageConfig};
use std::{env, path::Path};
fn | () {
let out_dir = env::var("OUT_DIR").expect("no OUT_DIR, but cargo should provide it");
//ANCHOR: cpp_config
let cpp_cfg = CppConfig::new(
// ANCHOR: cpp_output
Path::new("..").join("cpp-part").join("rust-api"),
// ANCHOR_END: cpp_output
"rust".into(),
)
.cpp_optiona... | main | identifier_name |
build.rs | use flapigen::{CppConfig, CppOptional, CppStrView, CppVariant, LanguageConfig};
use std::{env, path::Path};
fn main() {
let out_dir = env::var("OUT_DIR").expect("no OUT_DIR, but cargo should provide it");
//ANCHOR: cpp_config
let cpp_cfg = CppConfig::new(
// ANCHOR: cpp_output
Path::new("..... | "rust".into(),
)
.cpp_optional(CppOptional::Boost)
.cpp_variant(CppVariant::Boost)
.cpp_str_view(CppStrView::Boost);
//ANCHOR_END: cpp_config
let swig_gen = flapigen::Generator::new(LanguageConfig::CppConfig(cpp_cfg));
swig_gen.expand(
"c++-api-for-rust",
// ANCHOR: rust... | // ANCHOR_END: cpp_output | random_line_split |
build.rs | use flapigen::{CppConfig, CppOptional, CppStrView, CppVariant, LanguageConfig};
use std::{env, path::Path};
fn main() | // ANCHOR: rust_output
&Path::new(&out_dir).join("cpp_glue.rs"),
// ANCHOR_END: rust_output
);
println!(
"cargo:rerun-if-changed={}",
Path::new("src").join("cpp_glue.rs.in").display()
);
}
| {
let out_dir = env::var("OUT_DIR").expect("no OUT_DIR, but cargo should provide it");
//ANCHOR: cpp_config
let cpp_cfg = CppConfig::new(
// ANCHOR: cpp_output
Path::new("..").join("cpp-part").join("rust-api"),
// ANCHOR_END: cpp_output
"rust".into(),
)
.cpp_optional(... | identifier_body |
vec_resize_to_zero.rs | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::{match_def_path, paths};
use if_chain::if_chain;
use rustc_ast::LitKind;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declar... | (&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if_chain! {
if let hir::ExprKind::MethodCall(path_segment, _, args, _) = expr.kind;
if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
if match_def_path(cx, method_def_id, &paths::VE... | check_expr | identifier_name |
vec_resize_to_zero.rs | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::{match_def_path, paths};
use if_chain::if_chain;
use rustc_ast::LitKind;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declar... | Applicability::MaybeIncorrect,
);
},
);
}
}
}
}
| {
if_chain! {
if let hir::ExprKind::MethodCall(path_segment, _, args, _) = expr.kind;
if let Some(method_def_id) = cx.typeck_results().type_dependent_def_id(expr.hir_id);
if match_def_path(cx, method_def_id, &paths::VEC_RESIZE) && args.len() == 3;
if let ExprKind:... | identifier_body |
vec_resize_to_zero.rs | use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::{match_def_path, paths};
use if_chain::if_chain;
use rustc_ast::LitKind;
use rustc_errors::Applicability;
use rustc_hir as hir;
use rustc_hir::{Expr, ExprKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_session::{declare_lint_pass, declar... | "clear()".to_string(),
Applicability::MaybeIncorrect,
);
},
);
}
}
}
} | method_call_span,
"...or you can empty the vector with", | random_line_split |
options.rs | // svgcleaner could help you to clean up your SVG files
// from unnecessary data.
// Copyright (C) 2012-2018 Evgeniy Reizner
//
// This program 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 ... | remove_unreferenced_ids: false,
trim_ids: false,
remove_text_attributes: false,
remove_unused_coordinates: false,
remove_default_attributes: false,
remove_xmlns_xlink_attribute: false,
remove_needless_attributes: false,
remo... | {
CleaningOptions {
remove_unused_defs: false,
convert_shapes: false,
remove_title: false,
remove_desc: false,
remove_metadata: false,
remove_dupl_linear_gradients: false,
remove_dupl_radial_gradients: false,
remove_... | identifier_body |
options.rs | // svgcleaner could help you to clean up your SVG files
// from unnecessary data.
// Copyright (C) 2012-2018 Evgeniy Reizner
//
// This program 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 ... | () -> CleaningOptions {
CleaningOptions {
remove_unused_defs: false,
convert_shapes: false,
remove_title: false,
remove_desc: false,
remove_metadata: false,
remove_dupl_linear_gradients: false,
remove_dupl_radial_gradients: fals... | default | identifier_name |
options.rs | // svgcleaner could help you to clean up your SVG files
// from unnecessary data.
// Copyright (C) 2012-2018 Evgeniy Reizner
//
// This program 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 ... | }
// Should all be 'false'.
impl Default for CleaningOptions {
fn default() -> CleaningOptions {
CleaningOptions {
remove_unused_defs: false,
convert_shapes: false,
remove_title: false,
remove_desc: false,
remove_metadata: false,
remov... | pub paths_coordinates_precision: u8,
// 1..12
pub transforms_precision: u8, | random_line_split |
lossy.rs | // Copyright 2012-2017 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
for Utf8LossyChunk { valid, broken } in self.chunks() {
// If we successfully decoded the whole chunk as a valid string then
// we can return a direct formatting of the string which will also
// respect various formatting flags if possible.
if valid.len() == sel... | {
return "".fmt(f)
} | conditional_block |
lossy.rs | // Copyright 2012-2017 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! error { () => ({
unsafe {
let r = Utf8LossyChunk {
valid: core_str::from_utf8_unchecked(&self.source[0..i_]),
broken: &self.source[i_..i],
};
... | if byte < 128 {
} else {
let w = core_str::utf8_char_width(byte); | random_line_split |
lossy.rs | // Copyright 2012-2017 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... |
}
/// Iterator over lossy UTF-8 string
#[unstable(feature = "str_internals", issue = "0")]
#[allow(missing_debug_implementations)]
pub struct Utf8LossyChunksIter<'a> {
source: &'a [u8],
}
#[unstable(feature = "str_internals", issue = "0")]
#[derive(PartialEq, Eq, Debug)]
pub struct Utf8LossyChunk<'a> {
/// ... | {
Utf8LossyChunksIter { source: &self.bytes }
} | identifier_body |
lossy.rs | // Copyright 2012-2017 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... | (xs: &[u8], i: usize) -> u8 {
*xs.get(i).unwrap_or(&0)
}
let mut i = 0;
while i < self.source.len() {
let i_ = i;
let byte = unsafe { *self.source.get_unchecked(i) };
i += 1;
if byte < 128 {
} else {
let ... | safe_get | identifier_name |
register.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Ben Gamari <bgamari@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2... | fn build_enum_variant(cx: &ExtCtxt, variant: &node::Variant)
-> ast::Variant {
let doc = match variant.docstring {
Some(d) => d.node.name.to_string(),
None => "no documentation".to_string(),
};
let docstring = format!("`0x{:x}`. {}",
variant.value.node,
... | vec!(P(item), copy_impl)
}
/// Build a variant of an `EnumField` | random_line_split |
register.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Ben Gamari <bgamari@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2... | <'a> {
builder: &'a mut Builder,
cx: &'a ExtCtxt<'a>,
}
impl<'a> node::RegVisitor for BuildRegStructs<'a> {
fn visit_prim_reg(&mut self, path: &Vec<String>, reg: &node::Reg,
fields: &Vec<node::Field>) {
let width = match reg.ty {
node::RegType::RegPrim(ref width, _) => width.node,
... | BuildRegStructs | identifier_name |
register.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Ben Gamari <bgamari@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2... |
}
impl<'a> BuildRegStructs<'a> {
pub fn new(builder: &'a mut Builder, cx: &'a ExtCtxt<'a>)
-> BuildRegStructs<'a> {
BuildRegStructs {builder: builder, cx: cx}
}
}
/// Build a field type if necessary (e.g. in the case of an `EnumField`)
fn build_field_type(cx: &ExtCtxt, path: &Vec<String>,
... | {
let width = match reg.ty {
node::RegType::RegPrim(ref width, _) => width.node,
_ => panic!("visit_prim_reg called with non-primitive register"),
};
for field in fields.iter() {
for item in build_field_type(self.cx, path, reg, field).into_iter() {
self.builder.push_item(item);
... | identifier_body |
constant.rs | // Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/license/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 distri... |
fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<reflection::Case<'a>> {
utils::default_find_case(self, expected, variable)
}
}
impl reflection::PredicateReflection for BooleanPredicate {
fn parameters<'a>(&'a self) -> Box<dyn Iterator<Item = reflection::Parameter<'a>> + 'a> ... | {
self.retval
} | identifier_body |
constant.rs | // Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/license/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 distri... | use crate::utils;
use crate::Predicate;
/// Predicate that always returns a constant (boolean) result.
///
/// This is created by the `predicate::always` and `predicate::never` functions.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct BooleanPredicate {
retval: bool,
}
impl<Item:?Sized> Predicate<Item> f... | use crate::reflection; | random_line_split |
constant.rs | // Copyright (c) 2018 The predicates-rs Project Developers.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/license/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 distri... | () -> BooleanPredicate {
BooleanPredicate { retval: false }
}
| never | identifier_name |
objc_interface_type.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
#[repr(transparent)]
#[derive(Clone)]
pub struct Foo(pub id);
impl std::ops::Deref f... | {
pub foo: Foo,
}
#[test]
fn bindgen_test_layout_FooStruct() {
assert_eq!(
::std::mem::size_of::<FooStruct>(),
8usize,
concat!("Size of: ", stringify!(FooStruct))
);
assert_eq!(
::std::mem::align_of::<FooStruct>(),
8usize,
concat!("Alignment of ", stringi... | FooStruct | identifier_name |
objc_interface_type.rs | #![allow(
dead_code,
non_snake_case,
non_camel_case_types,
non_upper_case_globals
)]
#![cfg(target_os = "macos")]
#[macro_use]
extern crate objc;
#[allow(non_camel_case_types)]
pub type id = *mut objc::runtime::Object;
#[repr(transparent)]
#[derive(Clone)]
pub struct Foo(pub id);
impl std::ops::Deref f... | );
}
impl Default for FooStruct {
fn default() -> Self {
let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
unsafe {
::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
s.assume_init()
}
}
}
extern "C" {
pub fn fooFunc(foo: Foo);
}
extern "C" {
pub stat... | random_line_split | |
od.rs | // Copyright 2016-2020 James Bostock. See the LICENSE file at the top-level
// directory of this distribution.
// An implementation of the od(1) command in Rust.
// See http://man.cat-v.org/unix-6th/1/od
use std::env;
use std::io;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::Read;
use std::io::Seek;
us... | (out: &mut BufWriter<Stdout>, data: &[u8])
-> io::Result<usize> {
for byte in data {
write!(out, " {:03o}", byte)?;
}
writeln!(out)?;
Ok(data.len())
}
/// Writes a chunk of output data as octal (16 bit) word values. Words are
/// assumed to be little endian.
fn write_oct_word... | write_oct_bytes | identifier_name |
od.rs | // Copyright 2016-2020 James Bostock. See the LICENSE file at the top-level
// directory of this distribution.
// An implementation of the od(1) command in Rust.
// See http://man.cat-v.org/unix-6th/1/od
use std::env;
use std::io;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::Read;
use std::io::Seek;
us... |
/// Writes a chunk of output data as octal (16 bit) word values. Words are
/// assumed to be little endian.
fn write_oct_words(out: &mut BufWriter<Stdout>, data: &[u8])
-> io::Result<usize> {
for word in data.chunks(2) {
write!(out, " {:06o}", u16::from(word[1]) << 8 | u16::from(word[0... | {
for byte in data {
write!(out, " {:03o}", byte)?;
}
writeln!(out)?;
Ok(data.len())
} | identifier_body |
od.rs | // Copyright 2016-2020 James Bostock. See the LICENSE file at the top-level
// directory of this distribution.
// An implementation of the od(1) command in Rust.
// See http://man.cat-v.org/unix-6th/1/od
use std::env;
use std::io;
use std::io::BufReader;
use std::io::BufWriter;
use std::io::Read;
use std::io::Seek;
us... | Ok(data.len())
}
/// Writes a chunk of data as ASCII, reverting to octal byte values for
/// non-printable characters. Standard escape sequences are supported.
fn write_ascii_chars(out: &mut BufWriter<Stdout>, data: &[u8])
-> io::Result<usize> {
for byte in data {
match *byte {
... | for word in data.chunks(2) {
write!(out, " {:06x}", u16::from(word[1]) << 8 | u16::from(word[0]))?;
}
writeln!(out)?; | random_line_split |
mod.rs | // Copyright © 2020 Cormac O'Brien
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, ... | &mut self, msg_times: [Duration; 2], update: EntityUpdate) {
// enable lerping
self.force_link = false;
if update.no_lerp || self.msg_time!= msg_times[1] {
self.force_link = true;
}
self.msg_time = msg_times[0];
// fill in missing values from baseline
... | pdate( | identifier_name |
mod.rs | // Copyright © 2020 Cormac O'Brien
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, ... | }
}
pub fn uninitialized() -> ClientEntity {
ClientEntity {
force_link: false,
baseline: EntityState::uninitialized(),
msg_time: Duration::zero(),
msg_origins: [Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0)],
origin: Vector3... |
ClientEntity {
force_link: false,
baseline: baseline.clone(),
msg_time: Duration::zero(),
msg_origins: [Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0)],
origin: baseline.origin,
msg_angles: [
Vector3::new(Deg(0.0)... | identifier_body |
mod.rs | // Copyright © 2020 Cormac O'Brien
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, ... | pub fn from_baseline(baseline: EntityState) -> ClientEntity {
ClientEntity {
force_link: false,
baseline: baseline.clone(),
msg_time: Duration::zero(),
msg_origins: [Vector3::new(0.0, 0.0, 0.0), Vector3::new(0.0, 0.0, 0.0)],
origin: baseline.origin... | }
impl ClientEntity { | random_line_split |
mod.rs | // Copyright © 2020 Cormac O'Brien
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, ... | }
radius
}
/// Returns `true` if the light should be retained at the specified time.
pub fn retain(&mut self, time: Duration) -> bool {
self.spawned + self.ttl > time
}
}
/// A set of active dynamic lights.
pub struct Lights {
slab: LinkedSlab<Light>,
}
impl Lights {
... |
return 0.0;
}
| conditional_block |
arcvec.rs | use std::sync::Arc;
use std::fmt;
use std::ops::Deref;
#[derive(Clone)]
pub struct ArcVec<T> {
data: Arc<Vec<T>>,
offset: usize,
length: usize,
}
impl <T> ArcVec<T> {
pub fn new(data: Vec<T>) -> ArcVec<T> { | ArcVec {
data: Arc::new(data),
offset: 0,
length: length
}
}
pub fn offset(mut self, offset: usize) -> ArcVec<T> {
assert!(offset <= self.length);
self.offset += offset;
self.length -= offset;
self
}
pub fn limit(mut... | let length = data.len(); | random_line_split |
arcvec.rs | use std::sync::Arc;
use std::fmt;
use std::ops::Deref;
#[derive(Clone)]
pub struct | <T> {
data: Arc<Vec<T>>,
offset: usize,
length: usize,
}
impl <T> ArcVec<T> {
pub fn new(data: Vec<T>) -> ArcVec<T> {
let length = data.len();
ArcVec {
data: Arc::new(data),
offset: 0,
length: length
}
}
pub fn offset(mut self, offset... | ArcVec | identifier_name |
sieve.rs | extern crate sieve;
#[test]
fn limit_lower_than_the_first_prime() {
assert_eq!(sieve::primes_up_to(1), []);
}
#[test]
fn limit_is_the_first_prime() {
assert_eq!(sieve::primes_up_to(2), [2]);
}
#[test]
fn primes_up_to_10() {
assert_eq!(sieve::primes_up_to(10), [2, 3, 5, 7]);
}
#[test]
fn limit_of_1000()... | 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809,
811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907,
911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997];
assert_eq!(sieve::primes_up_... | random_line_split | |
sieve.rs | extern crate sieve;
#[test]
fn limit_lower_than_the_first_prime() {
assert_eq!(sieve::primes_up_to(1), []);
}
#[test]
fn limit_is_the_first_prime() |
#[test]
fn primes_up_to_10() {
assert_eq!(sieve::primes_up_to(10), [2, 3, 5, 7]);
}
#[test]
fn limit_of_1000() {
let expected = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149,
... | {
assert_eq!(sieve::primes_up_to(2), [2]);
} | identifier_body |
sieve.rs | extern crate sieve;
#[test]
fn | () {
assert_eq!(sieve::primes_up_to(1), []);
}
#[test]
fn limit_is_the_first_prime() {
assert_eq!(sieve::primes_up_to(2), [2]);
}
#[test]
fn primes_up_to_10() {
assert_eq!(sieve::primes_up_to(10), [2, 3, 5, 7]);
}
#[test]
fn limit_of_1000() {
let expected = vec![2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 3... | limit_lower_than_the_first_prime | identifier_name |
shim.rs | use std::marker::PhantomData;
// FIXME: remove this and use std::ptr::NonNull when Firefox requires Rust 1.25+
pub struct NonZeroPtr<T:'static>(&'static T);
impl<T:'static> NonZeroPtr<T> {
pub unsafe fn new_unchecked(ptr: *mut T) -> Self {
NonZeroPtr(&*ptr)
}
pub fn as_ptr(&self) -> *mut T {
... | (&self) -> &mut T {
&mut *self.ptr.as_ptr()
}
}
impl<'a, T> From<&'a mut T> for Shared<T> {
fn from(reference: &'a mut T) -> Self {
unsafe { Shared::new_unchecked(reference) }
}
}
| as_mut | identifier_name |
shim.rs | use std::marker::PhantomData; | impl<T:'static> NonZeroPtr<T> {
pub unsafe fn new_unchecked(ptr: *mut T) -> Self {
NonZeroPtr(&*ptr)
}
pub fn as_ptr(&self) -> *mut T {
self.0 as *const T as *mut T
}
}
pub struct Unique<T:'static> {
ptr: NonZeroPtr<T>,
_marker: PhantomData<T>,
}
impl<T:'static> Unique<T> {
... |
// FIXME: remove this and use std::ptr::NonNull when Firefox requires Rust 1.25+
pub struct NonZeroPtr<T: 'static>(&'static T);
| random_line_split |
wrong-mul-method-signature.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 ... | (self, s: &f64) -> Vec1 {
//~^ ERROR method `mul` has an incompatible type for trait
Vec1 {
x: self.x * *s
}
}
}
struct Vec2 {
x: f64,
y: f64
}
// Wrong type parameter ordering
impl Mul<Vec2> for Vec2 {
type Output = f64;
fn mul(self, s: f64) -> Vec2 {
//~^ ERR... | mul | identifier_name |
wrong-mul-method-signature.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 ... |
struct Vec1 {
x: f64
}
// Expecting value in input signature
impl Mul<f64> for Vec1 {
type Output = Vec1;
fn mul(self, s: &f64) -> Vec1 {
//~^ ERROR method `mul` has an incompatible type for trait
Vec1 {
x: self.x * *s
}
}
}
struct Vec2 {
x: f64,
y: f64
}
// ... | // method for an operator is not implemented properly.
// (In this case the mul method should take &f64 and not f64)
// See: #11450
use std::ops::Mul; | random_line_split |
wrong-mul-method-signature.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 ... |
}
struct Vec3 {
x: f64,
y: f64,
z: f64
}
// Unexpected return type
impl Mul<f64> for Vec3 {
type Output = i32;
fn mul(self, s: f64) -> f64 {
//~^ ERROR method `mul` has an incompatible type for trait
s
}
}
pub fn main() {
// Check that the usage goes from the trait declarati... | {
//~^ ERROR method `mul` has an incompatible type for trait
Vec2 {
x: self.x * s,
y: self.y * s
}
} | identifier_body |
car_factory.rs | use super::car_type::{Body, CarType, Colour};
pub struct | {
car_types: Vec<CarType>,
}
impl CarFactory {
pub fn new() -> CarFactory {
CarFactory {
car_types: Vec::new(),
}
}
pub fn get_car_type_id(&mut self, body: Body, colour: Colour) -> u8 {
let position = self.car_types
.iter()
.position(|ref r| r... | CarFactory | identifier_name |
car_factory.rs | use super::car_type::{Body, CarType, Colour};
pub struct CarFactory {
car_types: Vec<CarType>,
}
impl CarFactory {
pub fn new() -> CarFactory {
CarFactory {
car_types: Vec::new(),
}
}
pub fn get_car_type_id(&mut self, body: Body, colour: Colour) -> u8 {
let positio... | println!("Number of car types: {}", self.car_types.len());
}
} |
pub fn print(&self) { | random_line_split |
car_factory.rs | use super::car_type::{Body, CarType, Colour};
pub struct CarFactory {
car_types: Vec<CarType>,
}
impl CarFactory {
pub fn new() -> CarFactory {
CarFactory {
car_types: Vec::new(),
}
}
pub fn get_car_type_id(&mut self, body: Body, colour: Colour) -> u8 {
let positio... |
pub fn print(&self) {
println!("Number of car types: {}", self.car_types.len());
}
}
| {
self.car_types.get(id as usize)
} | identifier_body |
test.rs | use std::path::PathBuf;
use crate::app::{config, ddns, index::Index, lastfm, playlist, settings, thumbnail, user, vfs};
use crate::db::DB;
use crate::test::*;
pub struct Context {
pub db: DB,
pub index: Index,
pub config_manager: config::Manager,
pub ddns_manager: ddns::Manager,
pub lastfm_manager: lastfm::Manag... | (mut self, name: &str, source: &str) -> Self {
self.config
.mount_dirs
.get_or_insert(Vec::new())
.push(vfs::MountDir {
name: name.to_owned(),
source: source.to_owned(),
});
self
}
pub fn build(self) -> Context {
let cache_output_dir = self.test_directory.join("cache");
let db_path = self... | mount | identifier_name |
test.rs | use std::path::PathBuf;
use crate::app::{config, ddns, index::Index, lastfm, playlist, settings, thumbnail, user, vfs};
use crate::db::DB;
use crate::test::*;
pub struct Context {
pub db: DB,
pub index: Index,
pub config_manager: config::Manager,
pub ddns_manager: ddns::Manager,
pub lastfm_manager: lastfm::Manag... | let user_manager = user::Manager::new(db.clone(), auth_secret);
let vfs_manager = vfs::Manager::new(db.clone());
let ddns_manager = ddns::Manager::new(db.clone());
let config_manager = config::Manager::new(
settings_manager.clone(),
user_manager.clone(),
vfs_manager.clone(),
ddns_manager.clone(),
... | let auth_secret = settings_manager.get_auth_secret().unwrap(); | random_line_split |
test.rs | use std::path::PathBuf;
use crate::app::{config, ddns, index::Index, lastfm, playlist, settings, thumbnail, user, vfs};
use crate::db::DB;
use crate::test::*;
pub struct Context {
pub db: DB,
pub index: Index,
pub config_manager: config::Manager,
pub ddns_manager: ddns::Manager,
pub lastfm_manager: lastfm::Manag... |
config_manager.apply(&self.config).unwrap();
Context {
db,
index,
config_manager,
ddns_manager,
lastfm_manager,
playlist_manager,
settings_manager,
thumbnail_manager,
user_manager,
vfs_manager,
test_directory: self.test_directory,
}
}
}
| {
let cache_output_dir = self.test_directory.join("cache");
let db_path = self.test_directory.join("db.sqlite");
let db = DB::new(&db_path).unwrap();
let settings_manager = settings::Manager::new(db.clone());
let auth_secret = settings_manager.get_auth_secret().unwrap();
let user_manager = user::Manager::n... | identifier_body |
base.rs | //! Base helper routines for a code generator.
use collections::Set;
use grammar::free_variables::FreeVariables;
use grammar::repr::*;
use lr1::core::*;
use rust::RustWrite;
use std::io::{self, Write};
use util::Sep;
/// Base struct for various kinds of code generator. The flavor of
/// code generator is customized b... | <F>(&mut self, body: F) -> io::Result<()>
where
F: FnOnce(&mut Self) -> io::Result<()>,
{
rust!(self.out, "");
rust!(self.out, "#[cfg_attr(rustfmt, rustfmt_skip)]");
rust!(self.out, "mod {}parse{} {{", self.prefix, self.start_symbol);
// these stylistic lints are annoyin... | write_parse_mod | identifier_name |
base.rs | //! Base helper routines for a code generator.
use collections::Set;
use grammar::free_variables::FreeVariables;
use grammar::repr::*;
use lr1::core::*;
use rust::RustWrite;
use std::io::{self, Write};
use util::Sep;
/// Base struct for various kinds of code generator. The flavor of
/// code generator is customized b... | }
Ok(())
}
pub fn end_parser_fn(&mut self) -> io::Result<()> {
rust!(self.out, "}}"); // fn
rust!(self.out, "}}"); // impl
Ok(())
}
/// Returns phantom data type that captures the user-declared type
/// parameters in a phantom-data. This helps with ensurin... | {
// otherwise, convert one from the `IntoIterator`
// supplied, using the `ToTriple` trait which inserts
// errors/locations etc if none are given
let clone_call = if self.repeatable { ".clone()" } else { "" };
rust!(
self.out,
... | conditional_block |
base.rs | //! Base helper routines for a code generator.
use collections::Set;
use grammar::free_variables::FreeVariables;
use grammar::repr::*;
use lr1::core::*;
use rust::RustWrite;
use std::io::{self, Write};
use util::Sep;
/// Base struct for various kinds of code generator. The flavor of
/// code generator is customized b... | {
rust!(self.out, "");
rust!(self.out, "#[cfg_attr(rustfmt, rustfmt_skip)]");
rust!(self.out, "mod {}parse{} {{", self.prefix, self.start_symbol);
// these stylistic lints are annoying for the generated code,
// which doesn't follow conventions:
rust!(
se... | random_line_split | |
base.rs | //! Base helper routines for a code generator.
use collections::Set;
use grammar::free_variables::FreeVariables;
use grammar::repr::*;
use lr1::core::*;
use rust::RustWrite;
use std::io::{self, Write};
use util::Sep;
/// Base struct for various kinds of code generator. The flavor of
/// code generator is customized b... | // **and** `'a` are referenced -- same with bounds like `T:
// Foo<U>`. If those were needed, then `'a` or `U` would also
// have to appear in the types.
debug!("filtered_type_params = {:?}", filtered_type_params);
let filtered_where_clauses: Vec<_> = grammar
.where_cl... | {
let referenced_ty_params: Set<_> = tys
.into_iter()
.flat_map(|t| t.free_variables(&grammar.type_parameters))
.collect();
let filtered_type_params: Vec<_> = grammar
.type_parameters
.iter()
.filter(|t| referenced_ty_params.contai... | identifier_body |
bluetoothremotegattserver.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::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::Blue... |
Root::from_ref(self)
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-disconnect
fn Disconnect(&self) {
self.connected.set(false);
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-getprimaryservice
fn GetPrima... | {
self.connected.set(true);
} | conditional_block |
bluetoothremotegattserver.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::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::Blue... | (&self) -> Root<BluetoothDevice> {
self.device.get()
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected
fn Connected(&self) -> bool {
self.connected.get()
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-co... | Device | identifier_name |
bluetoothremotegattserver.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::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::Blue... | }
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connected
fn Connected(&self) -> bool {
self.connected.get()
}
// https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-connect
fn Connect(&self) -> Root<BluetoothRemoteGATTServer... | // https://webbluetoothcg.github.io/web-bluetooth/#dom-bluetoothremotegattserver-device
fn Device(&self) -> Root<BluetoothDevice> {
self.device.get() | random_line_split |
bluetoothremotegattserver.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::BluetoothRemoteGATTServerBinding;
use dom::bindings::codegen::Bindings::Blue... |
}
| {
//UNIMPLEMENTED
None
} | identifier_body |
slice-panic-1.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 x: &[_] = &[Foo, Foo];
x[3..4];
}
fn main() {
let _ = task::try(proc() foo());
unsafe { assert!(DTOR_COUNT == 2); }
}
| foo | identifier_name |
slice-panic-1.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 ... | unsafe { assert!(DTOR_COUNT == 2); }
} | random_line_split | |
slice-panic-1.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 _ = task::try(proc() foo());
unsafe { assert!(DTOR_COUNT == 2); }
} | identifier_body | |
c_str.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 ... | (&self) -> *const libc::c_char {
self.inner.as_ptr()
}
/// Convert this C string to a byte slice.
///
/// This function will calculate the length of this string (which normally
/// requires a linear amount of work to be done) and then return the
/// resulting slice of `u8` elements.
... | as_ptr | identifier_name |
c_str.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 ... | use slice;
use string::String;
use vec::Vec;
/// A type representing an owned C-compatible string
///
/// This type serves the primary purpose of being able to safely generate a
/// C-compatible string from a Rust byte slice or vector. An instance of this
/// type is a static guarantee that the underlying bytes contai... | use ops::Deref;
use option::Option::{self, Some, None};
use result::Result::{self, Ok, Err}; | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.