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 |
|---|---|---|---|---|
req.rs | use crate::codec::*;
use crate::endpoint::Endpoint;
use crate::error::*;
use crate::transport::AcceptStopHandle;
use crate::util::{Peer, PeerIdentity};
use crate::*;
use crate::{SocketType, ZmqResult};
use async_trait::async_trait;
use bytes::Bytes;
use crossbeam::queue::SegQueue;
use dashmap::DashMap;
use futures::{S... |
fn socket_options(&self) -> &SocketOptions {
&self.socket_options
}
fn shutdown(&self) {
self.peers.clear();
}
fn monitor(&self) -> &Mutex<Option<mpsc::Sender<SocketEvent>>> {
&self.socket_monitor
}
}
| {
SocketType::REQ
} | identifier_body |
req.rs | use crate::codec::*;
use crate::endpoint::Endpoint;
use crate::error::*;
use crate::transport::AcceptStopHandle;
use crate::util::{Peer, PeerIdentity};
use crate::*;
use crate::{SocketType, ZmqResult};
use async_trait::async_trait;
use bytes::Bytes;
use crossbeam::queue::SegQueue;
use dashmap::DashMap;
use futures::{S... | {
backend: Arc<ReqSocketBackend>,
current_request: Option<PeerIdentity>,
binds: HashMap<Endpoint, AcceptStopHandle>,
}
impl Drop for ReqSocket {
fn drop(&mut self) {
self.backend.shutdown();
}
}
#[async_trait]
impl SocketSend for ReqSocket {
async fn send(&mut self, mut message: ZmqMe... | ReqSocket | identifier_name |
element_data.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::flow::inline::InlineLevelBox;
use crate::flow::BlockLevelBox;
use atomic_refcell::AtomicRefCell;
use s... | BlockLevel(Arc<BlockLevelBox>),
InlineLevel(Arc<InlineLevelBox>),
} | random_line_split | |
element_data.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::flow::inline::InlineLevelBox;
use crate::flow::BlockLevelBox;
use atomic_refcell::AtomicRefCell;
use s... | {
pub(super) self_box: Arc<AtomicRefCell<Option<LayoutBox>>>,
pub(super) pseudo_elements: Option<Box<PseudoElementBoxes>>,
}
#[derive(Default)]
pub(super) struct PseudoElementBoxes {
pub before: Arc<AtomicRefCell<Option<LayoutBox>>>,
pub after: Arc<AtomicRefCell<Option<LayoutBox>>>,
}
pub(super) enum... | LayoutDataForElement | identifier_name |
lookahead.rs | use bit_set::{self, BitSet};
use collections::Collection;
use lr1::core::*;
use lr1::tls::Lr1Tls;
use std::fmt::{Debug, Error, Formatter};
use std::hash::Hash;
use grammar::repr::*;
pub trait Lookahead: Clone + Debug + Eq + Ord + Hash + Collection<Item = Self> {
fn fmt_as_item_suffix(&self, fmt: &mut Formatter) ->... |
})
})
}
}
impl<'debug> Debug for TokenSet {
fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> {
let terminals: Vec<_> = self.iter().collect();
Debug::fmt(&terminals, fmt)
}
}
impl<'iter> IntoIterator for &'iter TokenSet {
type IntoIter = TokenSetIter<'iter>;
... | {
Token::Terminal(terminals.all[bit].clone())
} | conditional_block |
lookahead.rs | use bit_set::{self, BitSet};
use collections::Collection;
use lr1::core::*;
use lr1::tls::Lr1Tls;
use std::fmt::{Debug, Error, Formatter};
use std::hash::Hash;
use grammar::repr::*;
pub trait Lookahead: Clone + Debug + Eq + Ord + Hash + Collection<Item = Self> {
fn fmt_as_item_suffix(&self, fmt: &mut Formatter) ->... | (&self, other: &TokenSet) -> bool {
!self.is_disjoint(other)
}
pub fn iter<'iter>(&'iter self) -> TokenSetIter<'iter> {
TokenSetIter {
bit_set: self.bit_set.iter(),
}
}
}
pub struct TokenSetIter<'iter> {
bit_set: bit_set::Iter<'iter, u32>,
}
impl<'iter> Iterator for... | is_intersecting | identifier_name |
lookahead.rs | use bit_set::{self, BitSet};
use collections::Collection;
use lr1::core::*;
use lr1::tls::Lr1Tls;
use std::fmt::{Debug, Error, Formatter};
use std::hash::Hash;
use grammar::repr::*;
pub trait Lookahead: Clone + Debug + Eq + Ord + Hash + Collection<Item = Self> {
fn fmt_as_item_suffix(&self, fmt: &mut Formatter) ->... |
pub fn contains(&self, token: &Token) -> bool {
self.bit_set.contains(self.bit(token))
}
pub fn contains_eof(&self) -> bool {
self.bit_set.contains(self.eof_bit())
}
/// If this set contains EOF, removes it from the set and returns
/// true. Otherwise, returns false.
pub ... | {
let mut bit_set = self.bit_set.clone();
bit_set.intersect_with(&set.bit_set);
TokenSet { bit_set: bit_set }
} | identifier_body |
lookahead.rs | use bit_set::{self, BitSet};
use collections::Collection;
use lr1::core::*;
use lr1::tls::Lr1Tls;
use std::fmt::{Debug, Error, Formatter};
use std::hash::Hash;
use grammar::repr::*;
pub trait Lookahead: Clone + Debug + Eq + Ord + Hash + Collection<Item = Self> {
fn fmt_as_item_suffix(&self, fmt: &mut Formatter) ->... | let mut conflicts = vec![];
for (terminal, &next_state) in &this_state.shifts {
conflicts.extend(
this_state
.reductions
.iter()
.map(|&(_, production)| Conflict {
state: index,
... |
fn conflicts<'grammar>(this_state: &State<'grammar, Self>) -> Vec<Conflict<'grammar, Self>> {
let index = this_state.index;
| random_line_split |
nif.rs | use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use syn::punctuated::Punctuated;
use syn::token::Comma;
pub fn transcoder_decorator(args: syn::AttributeArgs, fun: syn::ItemFn) -> TokenStream {
let sig = &fun.sig;
let name = &sig.ident;
let inputs = &sig.inputs;
validate_attributes(... |
if i == 0 && ident == "Env" {
continue;
}
if ident == "Env" {
panic!("Env must be the first argument in NIF functions");
}
};
} else {
panic!("unsupported input given: {:?}", stringi... | for (i, item) in inputs.iter().enumerate() {
if let syn::FnArg::Typed(ref typed) = item {
if let syn::Type::Path(syn::TypePath { path, .. }) = &*typed.ty {
let ident = path.segments.last().unwrap().ident.to_string(); | random_line_split |
nif.rs | use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use syn::punctuated::Punctuated;
use syn::token::Comma;
pub fn transcoder_decorator(args: syn::AttributeArgs, fun: syn::ItemFn) -> TokenStream {
let sig = &fun.sig;
let name = &sig.ident;
let inputs = &sig.inputs;
validate_attributes(... |
fn extract_inputs(inputs: Punctuated<syn::FnArg, Comma>) -> TokenStream {
let mut tokens = TokenStream::new();
let mut idx: usize = 0;
for item in inputs.iter() {
if let syn::FnArg::Typed(ref typed) = item {
let name = &typed.pat;
match &*typed.ty {
syn::T... | {
use syn::{Lit, Meta, MetaNameValue, NestedMeta};
for arg in args.iter() {
if let NestedMeta::Meta(Meta::NameValue(MetaNameValue { path, lit, .. })) = arg {
if path.is_ident(name) {
if let Lit::Str(lit) = lit {
return Some(lit.value());
}... | identifier_body |
nif.rs | use proc_macro2::{Span, TokenStream};
use quote::{quote, ToTokens};
use syn::punctuated::Punctuated;
use syn::token::Comma;
pub fn transcoder_decorator(args: syn::AttributeArgs, fun: syn::ItemFn) -> TokenStream {
let sig = &fun.sig;
let name = &sig.ident;
let inputs = &sig.inputs;
validate_attributes(... | (inputs: Punctuated<syn::FnArg, Comma>) -> TokenStream {
let mut tokens = TokenStream::new();
for item in inputs.iter() {
let name = if let syn::FnArg::Typed(ref typed) = item {
&typed.pat
} else {
panic!("unsupported input given: {:?}", stringify!(&item));
};
... | create_function_params | identifier_name |
addrinfo.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | fn drop(&mut self) {
unsafe { uvll::uv_freeaddrinfo(self.handle as *mut _) }
}
}
// Traverse the addrinfo linked list, producing a vector of Rust socket addresses
pub fn accum_addrinfo(addr: &Addrinfo) -> Vec<rtio::AddrinfoInfo> {
unsafe {
let mut addr = addr.handle;
let mut addrs ... | impl Drop for Addrinfo { | random_line_split |
addrinfo.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 hint = hints.map(|hint| {
libc::addrinfo {
ai_flags: 0,
ai_family: hint.family as c_int,
ai_socktype: 0,
ai_protocol: 0,
ai_addrlen: 0,
ai_canonname: null_mut(),
ai_addr: null_mut(),
... | {
assert!(node.is_some() || service.is_some());
let (_c_node, c_node_ptr) = match node {
Some(n) => {
let c_node = n.to_c_str();
let c_node_ptr = c_node.as_ptr();
(Some(c_node), c_node_ptr)
}
None => (None, null())
... | identifier_body |
addrinfo.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 ... | (req: *mut uvll::uv_getaddrinfo_t,
status: c_int,
res: *const libc::addrinfo) {
let req = Request::wrap(req);
assert!(status!= uvll::ECANCELED);
let cx: &mut Ctx = unsafe { req.get_data() };
cx.status = sta... | getaddrinfo_cb | identifier_name |
basic_shape.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/. */
//! CSS handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that ... | () -> Self { ShapeRadius::ClosestSide }
}
impl<L: ToCss> ToCss for ShapeRadius<L> {
#[inline]
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
match *self {
ShapeRadius::Length(ref lop) => lop.to_css(dest),
ShapeRadius::ClosestSide => dest.write_str("closes... | default | identifier_name |
basic_shape.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/. */
//! CSS handling for the [`basic-shape`](https://drafts.csswg.org/css-shapes/#typedef-basic-shape)
//! types that ... | "margin-box" => MarginBox,
"border-box" => BorderBox,
"padding-box" => PaddingBox,
"content-box" => ContentBox
);
add_impls_for_keyword_enum!(ShapeBox);
/// A shape source, for some reference box.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
#[derive(Clone, Debug, PartialEq... | pub type FloatAreaShape<BasicShape> = ShapeSource<BasicShape, ShapeBox>;
// https://drafts.csswg.org/css-shapes-1/#typedef-shape-box
define_css_keyword_enum!(ShapeBox: | random_line_split |
handle.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | let decrypted = master_key
.decrypt(&encrypted_keyset.encrypted_keyset, associated_data)
.map_err(|e| wrap_err("keyset::Handle: decryption failed", e))?;
Keyset::decode(&decrypted[..]).map_err(|_| TinkError::new("keyset::Handle:: invalid keyset"))
}
/// Encrypt a keyset with a master key.
fn encr... | associated_data: &[u8],
) -> Result<Keyset, TinkError> { | random_line_split |
handle.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
/// Create a `Handle` from a [`Keyset`]. Implemented as a standalone method rather than
/// as an `impl` of the `From` trait so visibility can be restricted.
pub(crate) fn from_keyset(ks: Keyset) -> Result<Self, TinkError> {
Ok(Handle {
ks: validate_keyset(ks)?,
})
}
}
//... | {
self.ks.clone()
} | identifier_body |
handle.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | (kt: &tink_proto::KeyTemplate) -> Result<Self, TinkError> {
let mut ksm = super::Manager::new();
ksm.rotate(kt)
.map_err(|e| wrap_err("keyset::Handle: cannot generate new keyset", e))?;
ksm.handle()
.map_err(|e| wrap_err("keyset::Handle: cannot get keyset handle", e))
}... | new | identifier_name |
uniformbuffergl.rs | // Copyright (c) 2016-2018 Bruce Stenning. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of co... |
/// Set a 4x4-component matrix in part of the memory put aside for the named uniform buffer
///
/// uniform_name: The name of the uniform whose value should be set
/// value: The value to set for the uniform
fn set_matrix(&mut self, uniform_name: &str, value: &Mat4<f32>) {
self.underlying.... | {
self.underlying.set_vec3(uniform_name, value);
} | identifier_body |
uniformbuffergl.rs | // Copyright (c) 2016-2018 Bruce Stenning. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of co... | pub fn new(data: &UniformBufferBacking, ubo_handle: GLuint) -> UniformBufferGl {
UniformBufferGl {
underlying: data.clone(),
ubo_handle: ubo_handle,
}
}
/// Return the uniform buffer object handle
pub fn get_handle(&self) -> GLuint {
self.ubo_handle
}... | impl UniformBufferGl {
/// Constructor
///
/// data: Raw data for the uniform buffer
/// ubo_handle: The UBO object handle | random_line_split |
uniformbuffergl.rs | // Copyright (c) 2016-2018 Bruce Stenning. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
// 1. Redistributions of source code must retain the above copyright
// notice, this list of co... | (&mut self, uniform_name: &str, value: &Vec<f32>) {
self.underlying.set_float_vector(uniform_name, value);
}
}
| set_float_vector | identifier_name |
problem-0002.rs | /// Problem 2
///
/// Each new term in the Fibonacci sequence is generated by adding the previous
/// two terms. By starting with 1 and 2, the first 10 terms will be:
///
/// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...
///
/// By considering the terms in the Fibonacci sequence whose values do not
/// exceed four million... |
fib_a = fib_b;
fib_b = fib_c;
}
println!("Answer: {}", sum_even);
}
| {
sum_even += fib_c;
} | conditional_block |
problem-0002.rs | /// Problem 2
///
/// Each new term in the Fibonacci sequence is generated by adding the previous
/// two terms. By starting with 1 and 2, the first 10 terms will be:
///
/// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...
///
/// By considering the terms in the Fibonacci sequence whose values do not
/// exceed four million... | }
println!("Answer: {}", sum_even);
} | }
fib_a = fib_b;
fib_b = fib_c; | random_line_split |
problem-0002.rs | /// Problem 2
///
/// Each new term in the Fibonacci sequence is generated by adding the previous
/// two terms. By starting with 1 and 2, the first 10 terms will be:
///
/// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...
///
/// By considering the terms in the Fibonacci sequence whose values do not
/// exceed four million... | {
println!("Problem 2");
let mut fib_a: u32 = 1;
let mut fib_b: u32 = 2;
let mut sum_even: u32 = 2;
loop {
let fib_c: u32 = fib_a + fib_b;
if fib_c > 4000000 {
break
}
if (fib_c % 2) == 0 {
sum_even += fib_c;
}
fib_a = fib_b;
fib_b = fib_c;
}
println!("Answer: {}", sum_even);
} | identifier_body | |
problem-0002.rs | /// Problem 2
///
/// Each new term in the Fibonacci sequence is generated by adding the previous
/// two terms. By starting with 1 and 2, the first 10 terms will be:
///
/// 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...
///
/// By considering the terms in the Fibonacci sequence whose values do not
/// exceed four million... | () {
println!("Problem 2");
let mut fib_a: u32 = 1;
let mut fib_b: u32 = 2;
let mut sum_even: u32 = 2;
loop {
let fib_c: u32 = fib_a + fib_b;
if fib_c > 4000000 {
break
}
if (fib_c % 2) == 0 {
sum_even += fib_c;
}
fib_a = fib_b;
fib_b = fib_c;
}
println!("Answer: {}", sum_even);
}
| main | identifier_name |
markdown.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 ... | (input: &str, libs: HashSet<Path>, mut test_args: Vec<~str>) -> int {
let input_str = load_or_return!(input, 1, 2);
let mut collector = Collector::new(input.to_owned(), libs, true, true);
find_testable_code(input_str, &mut collector);
test_args.unshift(~"rustdoctest");
testing::test_main(test_args.... | test | identifier_name |
markdown.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 ... | output.push(input_p.filestem().unwrap());
output.set_extension("html");
let mut css = StrBuf::new();
for name in matches.opt_strs("markdown-css").iter() {
let s = format!("<link rel=\"stylesheet\" type=\"text/css\" href=\"{}\">\n", name);
css.push_str(s)
}
let input_str = load_... |
/// Render `input` (e.g. "foo.md") into an HTML file in `output`
/// (e.g. output = "bar" => "bar/foo.html").
pub fn render(input: &str, mut output: Path, matches: &getopts::Matches) -> int {
let input_p = Path::new(input); | random_line_split |
markdown.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 ... |
Ok(f) => f
};
let (metadata, text) = extract_leading_metadata(input_str);
if metadata.len() == 0 {
let _ = writeln!(&mut io::stderr(),
"invalid markdown file: expecting initial line with `%...TITLE...`");
return 5;
}
let title = metadata.get(0).as_s... | {
let _ = writeln!(&mut io::stderr(),
"error opening `{}` for writing: {}",
output.display(), e);
return 4;
} | conditional_block |
markdown.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 load_external_files(names: &[~str]) -> Option<~str> {
let mut out = StrBuf::new();
for name in names.iter() {
out.push_str(load_or_return!(name.as_slice(), None, None));
out.push_char('\n');
}
Some(out.into_owned())
}
/// Render `input` (e.g. "foo.md") into an HTML file in `output`... | {
let mut metadata = Vec::new();
for line in s.lines() {
if line.starts_with("%") {
// remove %<whitespace>
metadata.push(line.slice_from(1).trim_left())
} else {
let line_start_byte = s.subslice_offset(line);
return (metadata, s.slice_from(line_st... | identifier_body |
linkhack.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/. */
// Some crumminess to make sure we link correctly
#[cfg(target_os = "linux")]
#[link(name = "pthread")]
#[link(na... | #[link(name = "js_static")]
#[link(name = "stdc++")]
#[link(name = "z")]
extern { }
//Avoid hard linking with stdc++ in android ndk cross toolchain
//It is hard to find location of android system libs in this rust source file
//and also we need to size down for mobile app packaging
#[cfg(target_os = "android")]
#[link... | random_line_split | |
token.rs | Literals */
LIT_INT(i64, ast::int_ty),
LIT_UINT(u64, ast::uint_ty),
LIT_INT_UNSUFFIXED(i64),
LIT_FLOAT(ast::ident, ast::float_ty),
LIT_FLOAT_UNSUFFIXED(ast::ident),
LIT_STR(ast::ident),
/* Name components */
// an identifier contains an "is_mod_name" boolean,
// indicating whether ... | (o: binop) -> ~str {
match o {
PLUS => ~"+",
MINUS => ~"-",
STAR => ~"*",
SLASH => ~"/",
PERCENT => ~"%",
CARET => ~"^",
AND => ~"&",
OR => ~"|",
SHL => ~"<<",
SHR => ~">>"
}
}
pub fn to_str(in: @ident_interner, t: &Token) -> ~str {
match *t {
... | binop_to_str | identifier_name |
token.rs | LBRACE => ~"{",
RBRACE => ~"}",
POUND => ~"#",
DOLLAR => ~"$",
/* Literals */
LIT_INT(c, ast::ty_char) => {
let mut res = ~"'";
do (c as char).escape_default |c| {
res.push_char(c);
}
res.push_char('\'');
res
}
... | {
match *tok {
token::IDENT(sid, false) => match sid.name {
8 | 27 | 32 .. 65 => true,
_ => false,
},
_ => false
}
} | identifier_body | |
token.rs | /* Literals */
LIT_INT(i64, ast::int_ty),
LIT_UINT(u64, ast::uint_ty),
LIT_INT_UNSUFFIXED(i64),
LIT_FLOAT(ast::ident, ast::float_ty),
LIT_FLOAT_UNSUFFIXED(ast::ident),
LIT_STR(ast::ident),
/* Name components */
// an identifier contains an "is_mod_name" boolean,
// indicating wheth... | "tt", // 17
"matchers", // 18
"str", // 19
"arg", // 20
"descrim", // 21
"__rust_abi", // 22
"__rust_stack_shim", // 23
"main", // 24
"<opaque>", //... | "ident", // 15
"path", // 16 | random_line_split |
admin_sockets.rs | // Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law... | (cmd: &str, socket: &str) -> RadosResult<String> {
let raw_cmd = format!("{{\"{}\": \"{}\"}}", "prefix", cmd);
admin_socket_raw_command(&raw_cmd, socket)
}
/// This function supports a raw command in the format of something like: `{"prefix": "help"}`.
/// The returned `String` will be a JSON String.
#[allow(un... | admin_socket_command | identifier_name |
admin_sockets.rs | // Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#![cfg(target_os = "linux")]
use std::str;
use std::io::{Read, Write, Cursor};
use std::os::unix::net::UnixStream;
use std::net::Shutdown... | //
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, | random_line_split |
admin_sockets.rs | // Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law... |
// The first 4 bytes are Big Endian unsigned int
let mut rdr = Cursor::new(buffer);
let len = rdr.read_u32::<BigEndian>().unwrap();
// Not currently using the len but may...
let rb = try!(stream.read_to_string(&mut output));
try!(stream.shutdown(Shutdown::Both));
Ok(output)
}
| {
try!(stream.shutdown(Shutdown::Both));
return Err(RadosError::new("Admin socket: Invalid command or socket did not return any data".to_string()));
} | conditional_block |
admin_sockets.rs | // Copyright 2017 LambdaStack All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law... |
/// This function supports a raw command in the format of something like: `{"prefix": "help"}`.
/// The returned `String` will be a JSON String.
#[allow(unused_variables)]
pub fn admin_socket_raw_command(cmd: &str, socket: &str) -> RadosResult<String> {
let mut output = String::new();
let mut buffer = vec![0;... | {
let raw_cmd = format!("{{\"{}\": \"{}\"}}", "prefix", cmd);
admin_socket_raw_command(&raw_cmd, socket)
} | identifier_body |
small_objects_stress.rs |
extern crate stopwatch;
use stopwatch::Stopwatch;
extern crate mo_gc;
use mo_gc::{GcThread, GcRoot, Trace, StatsLogger};
const THING_SIZE: usize = 8;
const THING_COUNT: i64 = 2500000;
struct Thing {
_data: [u64; THING_SIZE],
}
impl Thing {
fn new() -> Thing {
Thing { _data: [0; THING_SIZE] }
... | {
let gc = GcThread::spawn_gc();
let app_handle1 = gc.spawn(|| app());
let app_handle2 = gc.spawn(|| app());
let logger = gc.join().expect("gc failed");
logger.dump_to_stdout();
app_handle1.join().expect("app failed");
app_handle2.join().expect("app failed");
} | identifier_body | |
small_objects_stress.rs |
extern crate stopwatch;
use stopwatch::Stopwatch;
extern crate mo_gc;
use mo_gc::{GcThread, GcRoot, Trace, StatsLogger};
const THING_SIZE: usize = 8;
const THING_COUNT: i64 = 2500000;
struct Thing {
_data: [u64; THING_SIZE],
}
impl Thing {
fn new() -> Thing {
Thing { _data: [0; THING_SIZE] }
... | () {
let sw = Stopwatch::start_new();
for _ in 0..THING_COUNT {
let _new = GcRoot::new(Thing::new());
}
let per_second = (THING_COUNT * 1000) / sw.elapsed_ms();
println!("app allocated {} objects at {} objects per second", THING_COUNT, per_second);
println!("app finished in {}ms", sw.e... | app | identifier_name |
small_objects_stress.rs | extern crate stopwatch;
use stopwatch::Stopwatch;
extern crate mo_gc;
use mo_gc::{GcThread, GcRoot, Trace, StatsLogger};
const THING_SIZE: usize = 8;
const THING_COUNT: i64 = 2500000;
struct Thing {
_data: [u64; THING_SIZE],
}
impl Thing {
fn new() -> Thing {
Thing { _data: [0; THING_SIZE] }
... | } | random_line_split | |
illegal-proc-macro-derive-use.rs | // Copyright 2016 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: proc_macro::TokenStream) -> proc_macro::TokenStream {
a
}
// Issue #37590
#[proc_macro_derive(Foo)]
//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions
pub struct Foo {
}
fn main() {}
| foo | identifier_name |
illegal-proc-macro-derive-use.rs | // Copyright 2016 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
}
// Issue #37590
#[proc_macro_derive(Foo)]
//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions
pub struct Foo {
}
fn main() {} | extern crate proc_macro;
#[proc_macro_derive(Foo)]
//~^ ERROR: only usable with crates of the `proc-macro` crate type
pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream { | random_line_split |
illegal-proc-macro-derive-use.rs | // Copyright 2016 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 ... |
// Issue #37590
#[proc_macro_derive(Foo)]
//~^ ERROR: the `#[proc_macro_derive]` attribute may only be used on bare functions
pub struct Foo {
}
fn main() {}
| {
a
} | identifier_body |
window.rs | use error::Result;
use error::Error::Sdl as SdlError;
use sdl2::Sdl;
use sdl2::video::Window as SdlWindow;
use sdl2::video::{gl_attr, GLProfile, GLContext};
use libc::c_void;
use gl;
use sdl2;
const WINDOW_TITLE: &'static str = "Rusty Doom v0.0.7 - Toggle mouse with backtick key (`))";
const OPENGL_DEPTH_SIZE: u8 = 2... |
}
| {
check_gl_unsafe!(gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT));
} | identifier_body |
window.rs | use error::Result;
use error::Error::Sdl as SdlError;
use sdl2::Sdl;
use sdl2::video::Window as SdlWindow;
use sdl2::video::{gl_attr, GLProfile, GLContext};
use libc::c_void;
use gl;
use sdl2;
const WINDOW_TITLE: &'static str = "Rusty Doom v0.0.7 - Toggle mouse with backtick key (`))";
const OPENGL_DEPTH_SIZE: u8 = 2... | let window = try!(sdl.window(WINDOW_TITLE, width as u32, height as u32)
.position_centered()
.opengl()
.build()
.map_err(SdlError));
let context = try!(window.gl_create_context().map_err(SdlError));
sdl2::clear_error();
gl::load_with(|name| {
... | gl_attr::set_context_minor_version(gl::platform::GL_MINOR_VERSION);
gl_attr::set_depth_size(OPENGL_DEPTH_SIZE);
gl_attr::set_double_buffer(true);
| random_line_split |
window.rs | use error::Result;
use error::Error::Sdl as SdlError;
use sdl2::Sdl;
use sdl2::video::Window as SdlWindow;
use sdl2::video::{gl_attr, GLProfile, GLContext};
use libc::c_void;
use gl;
use sdl2;
const WINDOW_TITLE: &'static str = "Rusty Doom v0.0.7 - Toggle mouse with backtick key (`))";
const OPENGL_DEPTH_SIZE: u8 = 2... | (&self) -> f32 {
self.width as f32 / self.height as f32
}
pub fn swap_buffers(&self) {
self.window.gl_swap_window();
}
pub fn clear(&self) {
check_gl_unsafe!(gl::Clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT));
}
}
| aspect_ratio | identifier_name |
dinputd.rs | DEFINE_GUID!{IID_IDirectInputEffectDriver,
0x02538130, 0x898f, 0x11d0, 0x9a, 0xd0, 0x00, 0xa0, 0xc9, 0xa0, 0x6e, 0x35}
DEFINE_GUID!{IID_IDirectInputJoyConfig,
0x1de12ab1, 0xc9f5, 0x11cf, 0xbf, 0xc7, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}
DEFINE_GUID!{IID_IDirectInputPIDDriver,
0xeec6993a, 0xb3fd, 0x11d2, 0xa9,... | // 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.
// All files in the project carrying such notice may not be copied, modified, or distributed
// except according ... | random_line_split | |
engine.rs | use std::thread;
use std::collections::HashMap;
use std::intrinsics::type_name;
use std::mem;
use std::ptr::{self, Unique};
use std::sync::{Arc, Barrier, Mutex};
use std::time::Duration;
use bootstrap::input::ScanCode;
use bootstrap::window::Window;
use bootstrap::window::Message::*;
use bootstrap::time::Timer;
use bs... | }
}
/// Destroys the instance of the singleton.
unsafe fn destroy_instance() {
let ptr = mem::replace(&mut INSTANCE, ptr::null_mut());
Box::from_raw(ptr);
}
}
pub struct EngineBuilder {
systems: HashMap<SystemId, Box<System>>,
debug_systems: HashMap<SystemId, Box<System... | random_line_split | |
engine.rs | use std::thread;
use std::collections::HashMap;
use std::intrinsics::type_name;
use std::mem;
use std::ptr::{self, Unique};
use std::sync::{Arc, Barrier, Mutex};
use std::time::Duration;
use bootstrap::input::ScanCode;
use bootstrap::window::Window;
use bootstrap::window::Message::*;
use bootstrap::time::Timer;
use bs... | (engine: Engine) {
assert!(unsafe { INSTANCE.is_null() }, "Cannot create more than one Engine instance");
let boxed_engine = Box::new(engine);
unsafe {
INSTANCE = Box::into_raw(boxed_engine);
}
}
/// Retrieves an immutable reference to the singleton instance.
///... | set_instance | identifier_name |
engine.rs | use std::thread;
use std::collections::HashMap;
use std::intrinsics::type_name;
use std::mem;
use std::ptr::{self, Unique};
use std::sync::{Arc, Barrier, Mutex};
use std::time::Duration;
use bootstrap::input::ScanCode;
use bootstrap::window::Window;
use bootstrap::window::Message::*;
use bootstrap::time::Timer;
use bs... |
}
unsafe impl Singleton for Engine {
/// Creates the instance of the singleton.
fn set_instance(engine: Engine) {
assert!(unsafe { INSTANCE.is_null() }, "Cannot create more than one Engine instance");
let boxed_engine = Box::new(engine);
unsafe {
INSTANCE = Box::into_raw(bo... | {} | identifier_body |
ac97.rs | use alloc::boxed::Box;
use core::{cmp, ptr, mem};
use common::memory;
use schemes::{Resource, ResourceSeek, Url};
use common::time::{self, Duration};
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use schemes::{Result, KScheme};
use syscall::{Error, EBADF};
#[repr(packed)]
struct BD {
ptr: u... | (&mut self) -> Result<()> {
Err(Error::new(EBADF))
}
}
pub struct AC97 {
pub audio: usize,
pub bus_master: usize,
pub irq: u8,
}
impl KScheme for AC97 {
fn scheme(&self) -> &str {
"audio"
}
fn open(&mut self, _: &Url, _: usize) -> Result<Box<Resource>> {
Ok(box AC9... | sync | identifier_name |
ac97.rs | use alloc::boxed::Box;
use core::{cmp, ptr, mem};
use common::memory;
use schemes::{Resource, ResourceSeek, Url};
use common::time::{self, Duration};
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use schemes::{Result, KScheme};
use syscall::{Error, EBADF};
#[repr(packed)]
struct BD {
ptr: u... |
fn sync(&mut self) -> Result<()> {
Err(Error::new(EBADF))
}
}
pub struct AC97 {
pub audio: usize,
pub bus_master: usize,
pub irq: u8,
}
impl KScheme for AC97 {
fn scheme(&self) -> &str {
"audio"
}
fn open(&mut self, _: &Url, _: usize) -> Result<Box<Resource>> {
... | {
Err(Error::new(EBADF))
} | identifier_body |
ac97.rs | use alloc::boxed::Box;
use core::{cmp, ptr, mem};
use common::memory;
use schemes::{Resource, ResourceSeek, Url};
use common::time::{self, Duration};
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use schemes::{Result, KScheme};
use syscall::{Error, EBADF};
#[repr(packed)]
struct BD {
ptr: u... | po_cr.write(1);
wait = true;
}
}
po_lvi.write(lvi);
po_cr.write(1);
loop {
if po_civ.read() == lvi {
po_cr.write(0);
break;
}
... | random_line_split | |
ac97.rs | use alloc::boxed::Box;
use core::{cmp, ptr, mem};
use common::memory;
use schemes::{Resource, ResourceSeek, Url};
use common::time::{self, Duration};
use drivers::pci::config::PciConfig;
use drivers::io::{Io, Pio};
use schemes::{Result, KScheme};
use syscall::{Error, EBADF};
#[repr(packed)]
struct BD {
ptr: u... |
if lvi == start_lvi {
po_lvi.write(start_lvi);
po_cr.write(1);
wait = true;
}
}
po_lvi.write(lvi);
po_cr.write(1);
loop {
if po_civ.read() == lvi {
... | {
lvi = 0;
} | conditional_block |
local_http_server.rs | use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use printspool_auth::AuthContext;
use tracing::Instrument;
use warp::{Filter, http::Response as HttpResponse, hyper::Method};
use eyre::{
// eyre,
Result,
// Error,
// Context as _,
};
#[derive(Debug)]
pub struct InternalServerError... | } | random_line_split | |
local_http_server.rs | use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use printspool_auth::AuthContext;
use tracing::Instrument;
use warp::{Filter, http::Response as HttpResponse, hyper::Method};
use eyre::{
// eyre,
Result,
// Error,
// Context as _,
};
#[derive(Debug)]
pub struct InternalServerError... |
Ok(())
}
| {
// Disable CORS in production to prevent unauthorized 3D printer access from random websites
let routes = graphql_playground
.or(graphql_post)
.or(graphql_subscription);
warp::serve(routes).run(([0, 0, 0, 0], port)).await;
} | conditional_block |
local_http_server.rs | use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use printspool_auth::AuthContext;
use tracing::Instrument;
use warp::{Filter, http::Response as HttpResponse, hyper::Method};
use eyre::{
// eyre,
Result,
// Error,
// Context as _,
};
#[derive(Debug)]
pub struct InternalServerError... | (
db: &crate::Db,
schema_builder: crate::AppSchemaBuilder,
) -> Result<()> {
if &std::env::var("INSECURE_LOCAL_CONNECTION").unwrap_or("0".to_string()) == "0" {
debug!("Secure Connections Only: Insecure local connections are disabled.");
futures_util::future::pending::<()>().await;
re... | start | identifier_name |
local_http_server.rs | use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
use printspool_auth::AuthContext;
use tracing::Instrument;
use warp::{Filter, http::Response as HttpResponse, hyper::Method};
use eyre::{
// eyre,
Result,
// Error,
// Context as _,
};
#[derive(Debug)]
pub struct InternalServerError... | .finish();
let graphql_post = async_graphql_warp::graphql(schema.clone())
.and(warp::body::content_length_limit(1024 * 1024 * 1024))
.and_then(move |
graphql_tuple,
| {
let (schema, request): (
crate::AppSchema,
async_graphql::Req... | {
if &std::env::var("INSECURE_LOCAL_CONNECTION").unwrap_or("0".to_string()) == "0" {
debug!("Secure Connections Only: Insecure local connections are disabled.");
futures_util::future::pending::<()>().await;
return Ok(())
}
debug!("Insecure local connections are enabled");
let p... | identifier_body |
static-vec-autoref.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 ... | () {
assert_eq!(A[0], 5);
assert_eq!(B[1], 4);
assert_eq!(C[2], 3);
}
| main | identifier_name |
static-vec-autoref.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
struct T(&'static [int]);
static A: T = T(&'static [5, 4, 3]);
static B: T = T(&[5, 4, 3]);
static C: T = T([5, 4, 3]);
pub fn main() {
assert_eq!(A... | // 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 | random_line_split |
static-vec-autoref.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 ... | {
assert_eq!(A[0], 5);
assert_eq!(B[1], 4);
assert_eq!(C[2], 3);
} | identifier_body | |
cssconditionrule.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::CSSConditionRuleBinding::CSSConditionRuleMethods;
use dom::bindings::inherit... | pub struct CSSConditionRule {
cssgroupingrule: CSSGroupingRule,
}
impl CSSConditionRule {
pub fn new_inherited(parent_stylesheet: &CSSStyleSheet,
rules: Arc<Locked<StyleCssRules>>) -> CSSConditionRule {
CSSConditionRule {
cssgroupingrule: CSSGroupingRule::new_inheri... | use style::stylesheets::CssRules as StyleCssRules;
#[dom_struct] | random_line_split |
cssconditionrule.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::CSSConditionRuleBinding::CSSConditionRuleMethods;
use dom::bindings::inherit... | (&self) -> DOMString {
if let Some(rule) = self.downcast::<CSSMediaRule>() {
rule.get_condition_text()
} else if let Some(rule) = self.downcast::<CSSSupportsRule>() {
rule.get_condition_text()
} else {
unreachable!()
}
}
/// https://drafts.css... | ConditionText | identifier_name |
cssconditionrule.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::CSSConditionRuleBinding::CSSConditionRuleMethods;
use dom::bindings::inherit... |
pub fn shared_lock(&self) -> &SharedRwLock {
self.cssgroupingrule.shared_lock()
}
}
impl CSSConditionRuleMethods for CSSConditionRule {
/// https://drafts.csswg.org/css-conditional-3/#dom-cssconditionrule-conditiontext
fn ConditionText(&self) -> DOMString {
if let Some(rule) = self.do... | {
self.cssgroupingrule.parent_stylesheet()
} | identifier_body |
monomorphize.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... | (ccx: &CrateContext,
fn_id: ast::DefId,
real_substs: &subst::Substs,
ref_id: Option<ast::NodeId>)
-> (ValueRef, bool) {
debug!("monomorphic_fn(\
fn_id={}, \
real_substs={}, \
ref_id={:?})",
fn_id.rep... | monomorphic_fn | identifier_name |
monomorphize.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... | match ccx.monomorphized().borrow().find(&hash_id) {
Some(&val) => {
debug!("leaving monomorphic fn {}",
ty::item_path_str(ccx.tcx(), fn_id));
return (val, false);
}
None => ()
}
let psubsts = param_substs {
substs: (*real_substs).clone(),
... | {
debug!("monomorphic_fn(\
fn_id={}, \
real_substs={}, \
ref_id={:?})",
fn_id.repr(ccx.tcx()),
real_substs.repr(ccx.tcx()),
ref_id);
assert!(real_substs.types.all(|t| {
!ty::type_needs_infer(*t) && !ty::type_has_params(*t)
}));
... | identifier_body |
monomorphize.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... |
debug!("leaving monomorphic fn {}", ty::item_path_str(ccx.tcx(), fn_id));
(lldecl, true)
}
#[deriving(PartialEq, Eq, Hash)]
pub struct MonoId {
pub def: ast::DefId,
pub params: subst::VecPerParamSpace<ty::t>
} | }
};
ccx.monomorphizing().borrow_mut().insert(fn_id, depth); | random_line_split |
frontmatter.rs | use std::fmt;
use cobalt_config::DateTime;
use cobalt_config::SourceFormat;
use liquid;
use serde::Serialize;
use super::pagination;
use crate::error::Result;
#[derive(Debug, Eq, PartialEq, Default, Clone, Serialize)]
#[serde(deny_unknown_fields, default)]
pub struct Frontmatter {
pub permalink: cobalt_config::P... | (&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let converted = serde_yaml::to_string(self).expect("should always be valid");
let subset = converted
.strip_prefix("---")
.unwrap_or_else(|| converted.as_str())
.trim();
let converted = if subset == "{}" { "" }... | fmt | identifier_name |
frontmatter.rs | use std::fmt;
use cobalt_config::DateTime;
use cobalt_config::SourceFormat;
use liquid;
use serde::Serialize;
use super::pagination;
use crate::error::Result;
#[derive(Debug, Eq, PartialEq, Default, Clone, Serialize)]
#[serde(deny_unknown_fields, default)]
pub struct Frontmatter {
pub permalink: cobalt_config::P... |
let collection = collection.unwrap_or_default();
let permalink = permalink.unwrap_or_default();
if let Some(ref tags) = tags {
if tags.iter().any(|x| x.trim().is_empty()) {
failure::bail!("Empty strings are not allowed in tags");
}
}
let... | {
let cobalt_config::Frontmatter {
permalink,
slug,
title,
description,
excerpt,
categories,
tags,
excerpt_separator,
published_date,
format,
templated,
layout,
... | identifier_body |
frontmatter.rs | use std::fmt;
use cobalt_config::DateTime;
use cobalt_config::SourceFormat;
use liquid;
use serde::Serialize;
use super::pagination;
use crate::error::Result;
#[derive(Debug, Eq, PartialEq, Default, Clone, Serialize)]
#[serde(deny_unknown_fields, default)]
pub struct Frontmatter {
pub permalink: cobalt_config::P... | else { subset };
if converted.is_empty() {
Ok(())
} else {
write!(f, "{}", converted)
}
}
}
| { "" } | conditional_block |
frontmatter.rs | use std::fmt;
use cobalt_config::DateTime;
use cobalt_config::SourceFormat;
use liquid;
use serde::Serialize;
use super::pagination;
use crate::error::Result;
| pub permalink: cobalt_config::Permalink,
pub slug: kstring::KString,
pub title: kstring::KString,
pub description: Option<kstring::KString>,
pub excerpt: Option<kstring::KString>,
pub categories: Vec<kstring::KString>,
pub tags: Option<Vec<kstring::KString>>,
pub excerpt_separator: kstri... | #[derive(Debug, Eq, PartialEq, Default, Clone, Serialize)]
#[serde(deny_unknown_fields, default)]
pub struct Frontmatter { | random_line_split |
multi.rs | //!
//!
//! Multi reply info as used in old implementation (minus error mgmt TODO)
//! TODO with cached associated trait on info, could merge with error.rs??
use std::marker::PhantomData;
use super::super::{
BincErr,
RepInfo,
Info,
ReplyProvider,
SymProvider,
Peer,
};
use bincode::Infinite;
use bincode::{
... | fn read_read_info<R : Read>(&mut self, r : &mut R) -> Result<()> {
// as dest this is called multiple times and thus we redifine it
if let &mut MultipleReplyInfo::RouteReply(ref mut k) = self {
*k = bin_decode(r, Infinite).map_err(|e|BincErr(e))?;
}
Ok(())
}
}
impl<A : Serialize + Deserializ... | Ok(bin_decode(r, Infinite).map_err(|e|BincErr(e))?)
}
| identifier_body |
multi.rs | //!
//!
//! Multi reply info as used in old implementation (minus error mgmt TODO)
//! TODO with cached associated trait on info, could merge with error.rs??
use std::marker::PhantomData;
use super::super::{
BincErr,
RepInfo,
Info,
ReplyProvider,
SymProvider,
Peer,
};
use bincode::Infinite;
use bincode::{
... |
/// TODO remove called once
fn get_reply_key(&self) -> Option<&Vec<u8>> {
match self {
// &MultipleReplyInfo::RouteReply(ref k) => Some(k),
&MultipleReplyInfo::CachedRoute(ref k) => Some(k),
&MultipleReplyInfo::RouteReply(ref k) => Some(k),
_ => None,
}
}
}
/// TODO E as explicit... | random_line_split | |
multi.rs | //!
//!
//! Multi reply info as used in old implementation (minus error mgmt TODO)
//! TODO with cached associated trait on info, could merge with error.rs??
use std::marker::PhantomData;
use super::super::{
BincErr,
RepInfo,
Info,
ReplyProvider,
SymProvider,
Peer,
};
use bincode::Infinite;
use bincode::{
... | mut self, k : Vec<u8>) -> SSW {
self.symprov.new_sym_writer(k)
}
#[inline]
fn new_sym_reader (&mut self, k : Vec<u8>) -> SSR {
self.symprov.new_sym_reader(k)
}
}
impl<P : Peer,SSW,SSR,SP : SymProvider<SSW,SSR>> ReplyProvider<P, MultipleReplyInfo<<P as Peer>::Address>> for ReplyInfoProvider<P,SSW,SSR,S... | _sym_writer (& | identifier_name |
common.rs | use num::{Zero, One, Signed, Float};
use math::scalar::{BaseNum, BaseFloat};
use std::ops::{Add, Sub, Mul, Div, Index, Neg};
#[derive(Debug)]
pub enum Dimension2 {
X = 1,
Y = 2,
}
#[derive(Debug)]
pub enum Dimension3 {
X = 1,
Y = 2,
Z = 3,
}
pub trait ComponentWise where
Self: Index<usize>,
... | {
if dot(v1, v2) < U::Scalar::zero() {
-v1
} else {
v1
}
} | identifier_body | |
common.rs | use num::{Zero, One, Signed, Float};
use math::scalar::{BaseNum, BaseFloat};
use std::ops::{Add, Sub, Mul, Div, Index, Neg};
#[derive(Debug)]
pub enum Dimension2 {
X = 1,
Y = 2,
}
#[derive(Debug)]
pub enum Dimension3 {
X = 1,
Y = 2,
Z = 3,
}
pub trait ComponentWise where
Self: Index<usize>,
... | else {
v1
}
} | {
-v1
} | conditional_block |
common.rs | use num::{Zero, One, Signed, Float};
use math::scalar::{BaseNum, BaseFloat};
use std::ops::{Add, Sub, Mul, Div, Index, Neg};
#[derive(Debug)]
pub enum Dimension2 {
X = 1,
Y = 2,
}
#[derive(Debug)]
pub enum Dimension3 {
X = 1,
Y = 2,
Z = 3,
}
pub trait ComponentWise where
Self: Index<usize>,
... | <Self as ComponentWise>::Scalar: BaseNum + Signed {
fn abs(self) -> Self;
}
pub trait ComponentWiseFloat: ComponentWiseSigned where
<Self as ComponentWise>::Scalar: BaseFloat {
fn floor(self) -> Self;
fn ceil(self) -> Self;
}
pub trait VectorSpace: Copy + Clone where
Self: Zero,
Self: Ad... | fn max(self, other: Self) -> Self;
}
pub trait ComponentWiseSigned: ComponentWise where | random_line_split |
common.rs | use num::{Zero, One, Signed, Float};
use math::scalar::{BaseNum, BaseFloat};
use std::ops::{Add, Sub, Mul, Div, Index, Neg};
#[derive(Debug)]
pub enum Dimension2 {
X = 1,
Y = 2,
}
#[derive(Debug)]
pub enum Dimension3 {
X = 1,
Y = 2,
Z = 3,
}
pub trait ComponentWise where
Self: Index<usize>,
... | (self, other: Self, t: Self::Scalar) -> Self {
self * (Self::Scalar::one() - t) + other * t
}
}
pub fn dot<T: InnerProduct, U: InnerProduct<T>>(v1: U, v2: T) -> U::Scalar {
v1.dot(v2)
}
pub fn abs_dot<T: InnerProduct, U: InnerProduct<T>>(v1: U, v2: T) -> U::Scalar
where U::Scalar: Signed {
v1... | lerp | identifier_name |
failure.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 ... | (obj: &Any + Send, file: &'static str, line: uint) {
let msg = match obj.as_ref::<&'static str>() {
Some(s) => *s,
None => match obj.as_ref::<String>() {
Some(s) => s.as_slice(),
None => "Box<Any>",
}
};
let mut err = Stderr;
// It is assumed that all rea... | on_fail | identifier_name |
failure.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 on_fail(obj: &Any + Send, file: &'static str, line: uint) {
let msg = match obj.as_ref::<&'static str>() {
Some(s) => *s,
None => match obj.as_ref::<String>() {
Some(s) => s.as_slice(),
None => "Box<Any>",
}
};
let mut err = Stderr;
// It is as... | {
fn fmt_write<F: fmt::FormatWriter>(f: &mut F, bytes: &[u8]) {
let _ = f.write(bytes);
}
fmt_write(self, bytes);
Ok(())
} | identifier_body |
failure.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 ... |
// Defined in this module instead of io::stdio so that the unwinding
local_data_key!(pub local_stderr: Box<Writer + Send>)
impl Writer for Stdio {
fn write(&mut self, bytes: &[u8]) -> IoResult<()> {
fn fmt_write<F: fmt::FormatWriter>(f: &mut F, bytes: &[u8]) {
let _ = f.write(bytes);
}... | use rustrt::task::Task;
use str::Str;
use string::String; | random_line_split |
confirmations.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | let res = serde_json::to_string(&ConfirmationRequest::from(request));
let expected = r#"{"id":"0xf","payload":{"sign":{"address":"0x0000000000000000000000000000000000000001","hash":"0x0000000000000000000000000000000000000000000000000000000000000005"}}}"#;
// then
assert_eq!(res.unwrap(), expected.to_owned());
... | // when | random_line_split |
confirmations.rs | // Copyright 2015, 2016 Ethcore (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.... | <S>(&self, serializer: &mut S) -> Result<(), S::Error>
where S: Serializer
{
match *self {
ConfirmationResponse::SendTransaction(ref hash) => hash.serialize(serializer),
ConfirmationResponse::SignTransaction(ref rlp) => rlp.serialize(serializer),
ConfirmationResponse::Signature(ref signature) => signature... | serialize | identifier_name |
test_compile.rs | //! Test command for testing the code generator pipeline
//!
//! The `compile` test command runs each function through the full code generator pipeline
use cretonne::binemit;
use cretonne::ir;
use cretonne;
use cretonne::print_errors::pretty_error;
use cton_reader::TestCommand;
use subtest::{SubTest, Context, Result, ... |
fn put8(&mut self, _: u64) {
self.offset += 8;
}
fn reloc_ebb(&mut self, _reloc: binemit::Reloc, _ebb_offset: binemit::CodeOffset) {}
fn reloc_external(
&mut self,
_reloc: binemit::Reloc,
_name: &ir::ExternalName,
_addend: binemit::Addend,
) {
}
fn ... | {
self.offset += 4;
} | identifier_body |
test_compile.rs | //! Test command for testing the code generator pipeline
//!
//! The `compile` test command runs each function through the full code generator pipeline
use cretonne::binemit;
use cretonne::ir;
use cretonne;
use cretonne::print_errors::pretty_error;
use cton_reader::TestCommand;
use subtest::{SubTest, Context, Result, ... | else {
Ok(Box::new(TestCompile))
}
}
impl SubTest for TestCompile {
fn name(&self) -> Cow<str> {
Cow::from("compile")
}
fn is_mutating(&self) -> bool {
true
}
fn needs_isa(&self) -> bool {
true
}
fn run(&self, func: Cow<ir::Function>, context: &Contex... | {
Err(format!("No options allowed on {}", parsed))
} | conditional_block |
test_compile.rs | //! Test command for testing the code generator pipeline
//!
//! The `compile` test command runs each function through the full code generator pipeline
use cretonne::binemit;
use cretonne::ir;
use cretonne;
use cretonne::print_errors::pretty_error;
use cton_reader::TestCommand;
use subtest::{SubTest, Context, Result, ... | (parsed: &TestCommand) -> Result<Box<SubTest>> {
assert_eq!(parsed.command, "compile");
if!parsed.options.is_empty() {
Err(format!("No options allowed on {}", parsed))
} else {
Ok(Box::new(TestCompile))
}
}
impl SubTest for TestCompile {
fn name(&self) -> Cow<str> {
Cow::fro... | subtest | identifier_name |
test_compile.rs | //! Test command for testing the code generator pipeline
//!
//! The `compile` test command runs each function through the full code generator pipeline
use cretonne::binemit;
use cretonne::ir;
use cretonne;
use cretonne::print_errors::pretty_error;
use cton_reader::TestCommand;
use subtest::{SubTest, Context, Result, ... | "Expected code size {}, got {}",
code_size,
sink.offset
));
}
// Run final code through filecheck.
let mut text = String::new();
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
.map_err(|e| e.to_string())?... | if sink.offset != code_size {
return Err(format!( | random_line_split |
fragment_buffer.rs | use crate::{buffer::Settings, Cell};
pub use direction::Direction;
pub use fragment::Fragment;
pub use fragment_tree::FragmentTree;
use itertools::Itertools;
use std::{
collections::BTreeMap,
ops::{Deref, DerefMut},
};
pub mod direction;
pub mod fragment;
mod fragment_tree;
/// Fragment buffer contains the dr... | for (cell, shapes) in self.iter() {
buff.push_str(&format!("\ncell: {} ", cell));
for shape in shapes {
buff.push_str(&format!("\n {}", shape));
}
}
buff
}
/// Add a single fragment to this cell
pub fn add_fragment_to_cell(&mut self,... | buff = String::new();
| identifier_body |
fragment_buffer.rs | use crate::{buffer::Settings, Cell};
pub use direction::Direction;
pub use fragment::Fragment;
pub use fragment_tree::FragmentTree;
use itertools::Itertools;
use std::{
collections::BTreeMap,
ops::{Deref, DerefMut},
};
pub mod direction;
pub mod fragment;
mod fragment_tree;
/// Fragment buffer contains the dr... | {
*new_frag = new_frag.merge(&fragment).expect("should merge");
true
} else {
false
}
});
if!is_merged {
new_fragments.push(fragment);
}
}
new_fragments
}
}... | merge(&fragment) | identifier_name |
fragment_buffer.rs | use crate::{buffer::Settings, Cell};
pub use direction::Direction;
pub use fragment::Fragment;
pub use fragment_tree::FragmentTree;
use itertools::Itertools;
use std::{
collections::BTreeMap,
ops::{Deref, DerefMut},
};
pub mod direction;
pub mod fragment;
mod fragment_tree;
/// Fragment buffer contains the dr... | /// 5├─┼─┼─┼─┤ │ │ │ │ │
/// 6├─┼─┼─┼─┤ P├─Q─R─S─┤T
/// 7├─┼─┼─┼─┤ │ │ │ │ │
/// 8└─┴─┴─┴─┘ U└─┴─┴─┴─┘Y
/// ``` V W X
#[derive(Debug)]
pub struct FragmentBuffer(BTreeMap<Cell, Vec<Fragment>>);
impl Deref for FragmentBuffer {
type Target = BTreeMap<... | random_line_split | |
fragment_buffer.rs | use crate::{buffer::Settings, Cell};
pub use direction::Direction;
pub use fragment::Fragment;
pub use fragment_tree::FragmentTree;
use itertools::Itertools;
use std::{
collections::BTreeMap,
ops::{Deref, DerefMut},
};
pub mod direction;
pub mod fragment;
mod fragment_tree;
/// Fragment buffer contains the dr... | nds(&self) -> Option<(Cell, Cell)> {
let xlimits = self.iter().map(|(cell, _)| cell.x).minmax().into_option();
let ylimits = self.iter().map(|(cell, _)| cell.y).minmax().into_option();
match (xlimits, ylimits) {
(Some((min_x, max_x)), Some((min_y, max_y))) => {
Some((... | (*fragments).sort();
}
}
fn bou | conditional_block |
expr-if-box.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | ;
assert_eq!(rs, ~"happy");
}
pub fn main() { test_box(); test_str(); }
| { ~"sad" } | conditional_block |
expr-if-box.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | let rs = if true { @100 } else { @101 };
assert_eq!(*rs, 100);
}
fn test_str() {
let rs = if true { ~"happy" } else { ~"sad" };
assert_eq!(rs, ~"happy");
}
pub fn main() { test_box(); test_str(); } | // Tests for if as expressions returning boxed types
fn test_box() { | random_line_split |
expr-if-box.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let rs = if true { ~"happy" } else { ~"sad" };
assert_eq!(rs, ~"happy");
}
pub fn main() { test_box(); test_str(); }
| test_str | identifier_name |
expr-if-box.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn test_str() {
let rs = if true { ~"happy" } else { ~"sad" };
assert_eq!(rs, ~"happy");
}
pub fn main() { test_box(); test_str(); }
| {
let rs = if true { @100 } else { @101 };
assert_eq!(*rs, 100);
} | identifier_body |
writer.rs |
use interface::fill::fill;
use klv::klv::*;
use klv::ul::*;
use klv::value::*;
use klv::value::element::Element;
use klv::value::value_data::*;
use klv::value::partition::PartitionStatus::*;
use std::io::prelude::*;
use std::io::Cursor;
use serializer::encoder::*;
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub enum Co... | (&mut self, codec: Codec, wrapping: Wrapping) {
let mut properties : Box<Properties> = unsafe{ Box::from_raw(self.properties as *mut Properties) };
properties.streams.push(Stream{
codec: codec,
wrapping: wrapping
});
self.properties = Box::into_raw(properties) as *mut _;
}
pub fn ... | add_stream | identifier_name |
writer.rs | use klv::value::element::Element;
use klv::value::value_data::*;
use klv::value::partition::PartitionStatus::*;
use std::io::prelude::*;
use std::io::Cursor;
use serializer::encoder::*;
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub enum Codec {
Jpeg2000,
AvcIntra,
ProRes,
}
#[derive(Debug, Copy, Clone)]
#[repr(... | use interface::fill::fill;
use klv::klv::*;
use klv::ul::*;
use klv::value::*; | random_line_split | |
writer.rs |
use interface::fill::fill;
use klv::klv::*;
use klv::ul::*;
use klv::value::*;
use klv::value::element::Element;
use klv::value::value_data::*;
use klv::value::partition::PartitionStatus::*;
use std::io::prelude::*;
use std::io::Cursor;
use serializer::encoder::*;
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub enum Co... | ,
}
let primer_pack_klv = Klv {
key: Ul::PrimerPack,
value: Value {
elements: vec![
build_element!(Ul::Unknown, uint32 => 0),
build_element!(Ul::Unknown, uint32 => 18),
]
}
};
let mut stream = Cursor::new(vec![0; 0]);
stream.write(Encoder::seri... | {} | conditional_block |
writer.rs |
use interface::fill::fill;
use klv::klv::*;
use klv::ul::*;
use klv::value::*;
use klv::value::element::Element;
use klv::value::value_data::*;
use klv::value::partition::PartitionStatus::*;
use std::io::prelude::*;
use std::io::Cursor;
use serializer::encoder::*;
#[derive(Debug, Copy, Clone)]
#[repr(C)]
pub enum Co... |
#[no_mangle]
pub extern fn add_stream(mut writer: Writer, codec: Codec, wrapping: Wrapping) {
writer.add_stream(codec, wrapping);
}
#[no_mangle]
pub extern fn dump_header(mut writer: Writer) {
writer.dump_header();
}
#[no_mangle]
pub extern fn wrap(mut writer: Writer, data: *mut u8, size: usize, stream_id: u8) ... | {
Writer::new(handle, writer)
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.