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 |
|---|---|---|---|---|
sr_masterctl.rs | // SairaDB - A distributed database
// Copyright (C) 2015 by Siyu Wang
//
// 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 2
// of the License, or (at your option) any later ver... |
let stream = TcpStream::connect(addr);
//match stream.write_all(cookie.as_bytes());
}
}
fn master_connection() {
} | let addr: &str = &(ip + ":" + &port);
let count = Arc::new(AtomicUsize::new(0));
loop { | random_line_split |
diepdma0.rs | #[doc = "Register `DIEPDMA0` reader"]
pub struct R(crate::R<DIEPDMA0_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DIEPDMA0_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<DIEPDMA0_SPEC>> for R {
#[inline(always)]
fn from(reader: ... | (&self) -> DMAADDR_R {
DMAADDR_R::new((self.bits & 0xffff_ffff) as u32)
}
}
impl W {
#[doc = "Bits 0:31 - DMA Address"]
#[inline(always)]
pub fn dmaaddr(&mut self) -> DMAADDR_W {
DMAADDR_W { w: self }
}
#[doc = "Writes raw bits to the register."]
#[inline(always)]
pub uns... | dmaaddr | identifier_name |
diepdma0.rs | #[doc = "Register `DIEPDMA0` reader"]
pub struct R(crate::R<DIEPDMA0_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DIEPDMA0_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::R<DIEPDMA0_SPEC>> for R {
#[inline(always)]
fn from(reader: ... | impl core::ops::Deref for DMAADDR_R {
type Target = crate::FieldReader<u32, u32>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
#[doc = "Field `DMAAddr` writer - DMA Address"]
pub struct DMAADDR_W<'a> {
w: &'a mut W,
}
impl<'a> DMAADDR_W<'a> {
#[doc = r"Writes raw bits... | impl DMAADDR_R {
pub(crate) fn new(bits: u32) -> Self {
DMAADDR_R(crate::FieldReader::new(bits))
}
} | random_line_split |
borrowck-lend-flow-loop.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 cond() -> bool { panic!() }
fn produce<T>() -> T { panic!(); }
fn inc(v: &mut Box<int>) {
*v = box() (**v + 1);
}
fn loop_overarching_alias_mut() {
// In this instance, the borrow encompasses the entire loop.
let mut v = box 3;
let mut x = &mut v;
**x += 1;
loop {
borrow(&*v); //~... | {} | identifier_body |
borrowck-lend-flow-loop.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 loop_loop_pops_scopes<'r, F>(_v: &'r mut [uint], mut f: F) where F: FnMut(&'r mut uint) -> bool {
// Similar to `loop_break_pops_scopes` but for the `loop` keyword
while cond() {
while cond() {
// this borrow is limited to the scope of `r`...
let r: &'r mu... | {
break; // ...so it is not live as exit the `while` loop here
} | conditional_block |
borrowck-lend-flow-loop.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 ... | <'r, F>(_v: &'r mut [uint], mut f: F) where F: FnMut(&'r mut uint) -> bool {
// Similar to `loop_break_pops_scopes` but for the `loop` keyword
while cond() {
while cond() {
// this borrow is limited to the scope of `r`...
let r: &'r mut uint = produce();
if!f(&mut *r... | loop_loop_pops_scopes | identifier_name |
borrowck-lend-flow-loop.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 ... | // this borrow is limited to the scope of `r`...
let r: &'r mut uint = produce();
if!f(&mut *r) {
continue; //...so it is not live as exit (and re-enter) the `while` loop here
}
}
}
}
fn main() {} | random_line_split | |
source_loc_macros.rs | // This test makes sure that different expansions of the file!(), line!(),
// column!() macros get picked up by the incr. comp. hash.
// revisions:rpass1 rpass2
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#[rustc_clean(cfg="rpass2")]
fn line_same() {
let _ = line!();
}
#[rustc_clean(cfg="rpas... | () {
#[cfg(rpass1)]
{
let _ = column!();
}
#[cfg(rpass2)]
{
let _ = column!();
}
}
fn main() {
line_same();
line_different();
col_same();
col_different();
file_same();
}
| col_different | identifier_name |
source_loc_macros.rs | // This test makes sure that different expansions of the file!(), line!(),
// column!() macros get picked up by the incr. comp. hash.
// revisions:rpass1 rpass2
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#[rustc_clean(cfg="rpass2")]
fn line_same() {
let _ = line!();
}
#[rustc_clean(cfg="rpas... | fn col_different() {
#[cfg(rpass1)]
{
let _ = column!();
}
#[cfg(rpass2)]
{
let _ = column!();
}
}
fn main() {
line_same();
line_different();
col_same();
col_different();
file_same();
} | }
}
#[rustc_clean(except="hir_owner_nodes,optimized_mir", cfg="rpass2")] | random_line_split |
source_loc_macros.rs | // This test makes sure that different expansions of the file!(), line!(),
// column!() macros get picked up by the incr. comp. hash.
// revisions:rpass1 rpass2
// compile-flags: -Z query-dep-graph
#![feature(rustc_attrs)]
#[rustc_clean(cfg="rpass2")]
fn line_same() {
let _ = line!();
}
#[rustc_clean(cfg="rpas... | {
line_same();
line_different();
col_same();
col_different();
file_same();
} | identifier_body | |
insert_only.rs | use std::borrow::Borrow;
use std::boxed::Box;
use std::cell::{Cell, UnsafeCell};
use std::cmp::Eq;
use std::collections::hash_map::{self, Entry};
use std::collections::HashMap as Interior;
use std::hash::{BuildHasher, Hash};
#[derive(Debug)]
pub struct HashMap<K: Eq + Hash, V, S: BuildHasher = ::std::collections::hash... |
}
impl<K: Eq + Hash, V, S: BuildHasher> HashMap<K, V, S> {
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
HashMap {
data: UnsafeCell::new(Interior::with_hasher(hash_builder)),
inserting: Cell::new(false),
}
}
pub fn with_capacity_and_hasher(capacity: usize, hash_builder: S) -> Hash... | {
HashMap {
data: UnsafeCell::new(Interior::new()),
inserting: Cell::new(false),
}
} | identifier_body |
insert_only.rs | use std::borrow::Borrow;
use std::boxed::Box;
use std::cell::{Cell, UnsafeCell};
use std::cmp::Eq;
use std::collections::hash_map::{self, Entry};
use std::collections::HashMap as Interior;
use std::hash::{BuildHasher, Hash};
#[derive(Debug)]
pub struct HashMap<K: Eq + Hash, V, S: BuildHasher = ::std::collections::hash... | }
pub fn get_default<F>(&self, key: K, default_function: F) -> Option<&V>
where
F: FnOnce() -> Option<V>,
{
assert!(
!self.inserting.get(),
"Attempt to call get_default() on a insert_only::HashMap within the default_function \
callback for another get_default() on the same map"
);
... | random_line_split | |
insert_only.rs | use std::borrow::Borrow;
use std::boxed::Box;
use std::cell::{Cell, UnsafeCell};
use std::cmp::Eq;
use std::collections::hash_map::{self, Entry};
use std::collections::HashMap as Interior;
use std::hash::{BuildHasher, Hash};
#[derive(Debug)]
pub struct HashMap<K: Eq + Hash, V, S: BuildHasher = ::std::collections::hash... | (self) -> Self::IntoIter {
IntoIter {
data: self.data.into_inner().into_iter(),
}
}
}
| into_iter | identifier_name |
metadata.rs | use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use super::Error;
use crate::Error::MalformedMetadata;
#[derive(Debug)]
pub struct MetadataMap<'a>(HashMap<&'a str, &'a str>);
impl<'a> MetadataMap<'a> {
/// Returns a string that indicates the character set.
pub fn charset(&self) -> Option<&'a ... | }
} | map.insert("Plural-Forms", " n_plurals = 42 ; plural = n > 10 ");
assert_eq!(map.plural_forms(), (Some(42), Some("n > 10"))); | random_line_split |
metadata.rs | use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use super::Error;
use crate::Error::MalformedMetadata;
#[derive(Debug)]
pub struct | <'a>(HashMap<&'a str, &'a str>);
impl<'a> MetadataMap<'a> {
/// Returns a string that indicates the character set.
pub fn charset(&self) -> Option<&'a str> {
self.get("Content-Type")
.and_then(|x| x.split("charset=").nth(1))
}
/// Returns the number of different plurals and the bool... | MetadataMap | identifier_name |
metadata.rs | use std::collections::HashMap;
use std::ops::{Deref, DerefMut};
use super::Error;
use crate::Error::MalformedMetadata;
#[derive(Debug)]
pub struct MetadataMap<'a>(HashMap<&'a str, &'a str>);
impl<'a> MetadataMap<'a> {
/// Returns a string that indicates the character set.
pub fn charset(&self) -> Option<&'a ... |
}
impl<'a> Deref for MetadataMap<'a> {
type Target = HashMap<&'a str, &'a str>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'a> DerefMut for MetadataMap<'a> {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
pub fn parse_metadata(blob: &str) -> Result<Metada... | {
self.get("Plural-Forms")
.map(|f| {
f.split(';').fold((None, None), |(n_pl, pl), prop| {
match prop.chars().position(|c| c == '=') {
Some(index) => {
let (name, value) = prop.split_at(index);
... | identifier_body |
ip.rs | use pktparse::{ipv4, ipv6};
use std::fmt::Display;
use std::net::Ipv4Addr;
pub trait IPHeader {
type Addr: Display;
fn source_addr(&self) -> Self::Addr;
fn dest_addr(&self) -> Self::Addr;
}
impl IPHeader for ipv4::IPv4Header {
type Addr = Ipv4Addr;
#[inline]
fn source_addr(&self) -> Self::Ad... | (&self) -> Self::Addr {
self.dest_addr
}
}
impl IPHeader for ipv6::IPv6Header {
type Addr = String;
#[inline]
fn source_addr(&self) -> Self::Addr {
format!("[{}]", self.source_addr)
}
#[inline]
fn dest_addr(&self) -> Self::Addr {
format!("[{}]", self.dest_addr)
... | dest_addr | identifier_name |
ip.rs | use pktparse::{ipv4, ipv6}; |
fn source_addr(&self) -> Self::Addr;
fn dest_addr(&self) -> Self::Addr;
}
impl IPHeader for ipv4::IPv4Header {
type Addr = Ipv4Addr;
#[inline]
fn source_addr(&self) -> Self::Addr {
self.source_addr
}
#[inline]
fn dest_addr(&self) -> Self::Addr {
self.dest_addr
}
}... | use std::fmt::Display;
use std::net::Ipv4Addr;
pub trait IPHeader {
type Addr: Display; | random_line_split |
ip.rs | use pktparse::{ipv4, ipv6};
use std::fmt::Display;
use std::net::Ipv4Addr;
pub trait IPHeader {
type Addr: Display;
fn source_addr(&self) -> Self::Addr;
fn dest_addr(&self) -> Self::Addr;
}
impl IPHeader for ipv4::IPv4Header {
type Addr = Ipv4Addr;
#[inline]
fn source_addr(&self) -> Self::Ad... |
#[inline]
fn dest_addr(&self) -> Self::Addr {
format!("[{}]", self.dest_addr)
}
}
| {
format!("[{}]", self.source_addr)
} | identifier_body |
main.rs | fn main() | "May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"];
println!("Months of the year: {:?}", months);
} | {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let x = x + 1;
let x = x * 2;
println!("The value of x is: {}", x);
let tup = (500, 6.4, 1);
let (x, y, z) = tup;
println!("The value of x is: {}", x);
println!("The value of... | identifier_body |
main.rs | fn | () {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let x = x + 1;
let x = x * 2;
println!("The value of x is: {}", x);
let tup = (500, 6.4, 1);
let (x, y, z) = tup;
println!("The value of x is: {}", x);
println!("The value... | main | identifier_name |
main.rs | fn main() {
let mut x = 5;
println!("The value of x is: {}", x);
x = 6;
println!("The value of x is: {}", x);
let x = x + 1;
let x = x * 2;
println!("The value of x is: {}", x);
let tup = (500, 6.4, 1);
let (x, y, z) = tup;
println!("The value of x is: {}", x);
println!("Th... | "June",
"July",
"August",
"September",
"October",
"November",
"December"];
println!("Months of the year: {:?}", months);
} | "April",
"May", | random_line_split |
expr-copy.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... |
struct A { a: int }
pub fn main() {
let mut x = A {a: 10};
f(&mut x);
assert_eq!(x.a, 100);
x.a = 20;
let mut y = x;
f(&mut y);
assert_eq!(x.a, 20);
}
| {
arg.a = 100;
} | identifier_body |
expr-copy.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... | f(&mut x);
assert_eq!(x.a, 100);
x.a = 20;
let mut y = x;
f(&mut y);
assert_eq!(x.a, 20);
} | struct A { a: int }
pub fn main() {
let mut x = A {a: 10}; | random_line_split |
expr-copy.rs | // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | { a: int }
pub fn main() {
let mut x = A {a: 10};
f(&mut x);
assert_eq!(x.a, 100);
x.a = 20;
let mut y = x;
f(&mut y);
assert_eq!(x.a, 20);
}
| A | identifier_name |
issue-3794.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {
let s: Box<S> = box S { s: 5 };
print_s(&*s);
let t: Box<T> = s as Box<T>;
print_t(&*t);
}
| {
s.print();
} | identifier_body |
issue-3794.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 ... | s.print();
}
pub fn main() {
let s: Box<S> = box S { s: 5 };
print_s(&*s);
let t: Box<T> = s as Box<T>;
print_t(&*t);
} | fn print_t(t: &T) {
t.print();
}
fn print_s(s: &S) { | random_line_split |
issue-3794.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 ... | (s: &S) {
s.print();
}
pub fn main() {
let s: Box<S> = box S { s: 5 };
print_s(&*s);
let t: Box<T> = s as Box<T>;
print_t(&*t);
}
| print_s | identifier_name |
request.rs | //! Client Requests
use std::marker::PhantomData;
use std::io::{self, Write, BufWriter};
use std::net::Shutdown;
use url::Url;
use method::{self, Method};
use header::Headers;
use header::{self, Host};
use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming};
use http::{self, HttpWriter, LINE_ENDIN... |
}
impl Request<Streaming> {
/// Completes writing the request, and returns a response to read from.
///
/// Consumes the Request.
pub fn send(self) -> ::Result<Response> {
let mut raw = try!(self.body.end()).into_inner().unwrap(); // end() already flushes
if!http::should_keep_alive(sel... | { &mut self.headers } | identifier_body |
request.rs | //! Client Requests
use std::marker::PhantomData;
use std::io::{self, Write, BufWriter};
use std::net::Shutdown;
use url::Url;
use method::{self, Method};
use header::Headers;
use header::{self, Host};
use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming};
use http::{self, HttpWriter, LINE_ENDIN... | .into_inner().unwrap().downcast::<MockStream>().ok().unwrap();
let bytes = stream.write;
let s = from_utf8(&bytes[..]).unwrap();
assert!(!s.contains("Content-Length:"));
assert!(!s.contains("Transfer-Encoding:"));
}
#[test]
fn test_head_empty_body() {
let ... | ).unwrap();
let req = req.start().unwrap();
let stream = *req.body.end().unwrap() | random_line_split |
request.rs | //! Client Requests
use std::marker::PhantomData;
use std::io::{self, Write, BufWriter};
use std::net::Shutdown;
use url::Url;
use method::{self, Method};
use header::Headers;
use header::{self, Host};
use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming};
use http::{self, HttpWriter, LINE_ENDIN... | (&self) -> method::Method { self.method.clone() }
}
impl Request<Fresh> {
/// Create a new client request.
pub fn new(method: method::Method, url: Url) -> ::Result<Request<Fresh>> {
let mut conn = HttpConnector(None);
Request::with_connector(method, url, &mut conn)
}
/// Create a new c... | method | identifier_name |
request.rs | //! Client Requests
use std::marker::PhantomData;
use std::io::{self, Write, BufWriter};
use std::net::Shutdown;
use url::Url;
use method::{self, Method};
use header::Headers;
use header::{self, Host};
use net::{NetworkStream, NetworkConnector, HttpConnector, Fresh, Streaming};
use http::{self, HttpWriter, LINE_ENDIN... |
debug!("request line: {:?} {:?} {:?}", self.method, uri, self.version);
try!(write!(&mut self.body, "{} {} {}{}",
self.method, uri, self.version, LINE_ENDING));
let stream = match self.method {
Method::Get | Method::Head => {
debug!("headers={:... | {
uri.push('?');
uri.push_str(&q[..]);
} | conditional_block |
png2icns.rs | //! Creates an ICNS file containing a single image, read from a PNG file.
//!
//! To create an ICNS file from a PNG, run:
//!
//! ```shell
//! cargo run --example png2icns <path/to/file.png>
//! # ICNS will be saved to path/to/file.icns
//! ```
//!
//! Note that the dimensions of the input image must be exactly those o... | () {
let num_args = env::args().count();
if num_args < 2 || num_args > 3 {
println!("Usage: png2icns <path> [<ostype>]");
return;
}
let png_path = env::args().nth(1).unwrap();
let png_path = Path::new(&png_path);
let png_file = BufReader::new(File::open(png_path)
.expect("... | main | identifier_name |
png2icns.rs | //! Creates an ICNS file containing a single image, read from a PNG file.
//!
//! To create an ICNS file from a PNG, run:
//!
//! ```shell
//! cargo run --example png2icns <path/to/file.png>
//! # ICNS will be saved to path/to/file.icns
//! ```
//!
//! Note that the dimensions of the input image must be exactly those o... | png_path.with_extension("icns")
};
let icns_file = BufWriter::new(File::create(icns_path)
.expect("failed to create ICNS file"));
family.write(icns_file).expect("failed to write ICNS file");
} | png_path.with_extension(format!("{}.icns", ostype))
} else {
family.add_icon(&image).expect("failed to encode image"); | random_line_split |
png2icns.rs | //! Creates an ICNS file containing a single image, read from a PNG file.
//!
//! To create an ICNS file from a PNG, run:
//!
//! ```shell
//! cargo run --example png2icns <path/to/file.png>
//! # ICNS will be saved to path/to/file.icns
//! ```
//!
//! Note that the dimensions of the input image must be exactly those o... |
let png_path = env::args().nth(1).unwrap();
let png_path = Path::new(&png_path);
let png_file = BufReader::new(File::open(png_path)
.expect("failed to open PNG file"));
let image = Image::read_png(png_file).expect("failed to read PNG file");
let mut family = IconFamily::new();
let icns_p... | {
println!("Usage: png2icns <path> [<ostype>]");
return;
} | conditional_block |
png2icns.rs | //! Creates an ICNS file containing a single image, read from a PNG file.
//!
//! To create an ICNS file from a PNG, run:
//!
//! ```shell
//! cargo run --example png2icns <path/to/file.png>
//! # ICNS will be saved to path/to/file.icns
//! ```
//!
//! Note that the dimensions of the input image must be exactly those o... | family.add_icon(&image).expect("failed to encode image");
png_path.with_extension("icns")
};
let icns_file = BufWriter::new(File::create(icns_path)
.expect("failed to create ICNS file"));
family.write(icns_file).expect("failed to write ICNS file");
}
| {
let num_args = env::args().count();
if num_args < 2 || num_args > 3 {
println!("Usage: png2icns <path> [<ostype>]");
return;
}
let png_path = env::args().nth(1).unwrap();
let png_path = Path::new(&png_path);
let png_file = BufReader::new(File::open(png_path)
.expect("fa... | identifier_body |
margin.mako.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/. */
<%namespace name="helpers" file="/helpers.mako.rs" />
<% from data import DEFAULT_RULES_AND_PAGE %>
${helpers.fo... | "scroll-margin",
"scroll-margin-%s",
"specified::Length::parse",
engines="gecko",
spec="https://drafts.csswg.org/css-scroll-snap-1/#propdef-scroll-margin",
)}
${helpers.two_properties_shorthand(
"scroll-margin-block",
"scroll-margin-block-start",
"scroll-margin-block-end",
"specifie... | ${helpers.four_sides_shorthand( | random_line_split |
animation.rs | extern crate sdl2;
use std::path::Path;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::Point;
use sdl2::rect::Rect;
use std::time::Duration;
fn | () -> Result<(), String> {
let sdl_context = sdl2::init()?;
let video_subsystem = sdl_context.video()?;
let window = video_subsystem
.window("SDL2", 640, 480)
.position_centered()
.build()
.map_err(|e| e.to_string())?;
let mut canvas = window
.into_canvas()
.a... | main | identifier_name |
animation.rs | extern crate sdl2;
use std::path::Path;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::Point;
use sdl2::rect::Rect;
use std::time::Duration;
fn main() -> Result<(), String> {
let sdl_context = sdl2::init()?;
let video_subsystem = sdl_context.video()?;
let window = video_subsystem
... |
// Soldier - walk animation
let mut source_rect_2 = Rect::new(0, 64, sprite_tile_size.0, sprite_tile_size.0);
let mut dest_rect_2 = Rect::new(0, 64, sprite_tile_size.0 * 4, sprite_tile_size.0 * 4);
dest_rect_2.center_on(Point::new(440, 360));
let mut running = true;
while running {
for... | let mut dest_rect_1 = Rect::new(0, 32, sprite_tile_size.0 * 4, sprite_tile_size.0 * 4);
dest_rect_1.center_on(Point::new(0, 240)); | random_line_split |
animation.rs | extern crate sdl2;
use std::path::Path;
use sdl2::event::Event;
use sdl2::keyboard::Keycode;
use sdl2::rect::Point;
use sdl2::rect::Rect;
use std::time::Duration;
fn main() -> Result<(), String> |
let mut event_pump = sdl_context.event_pump()?;
// animation sheet and extras are available from
// https://opengameart.org/content/a-platformer-in-the-forest
let temp_surface = sdl2::surface::Surface::load_bmp(Path::new("assets/characters.bmp"))?;
let texture = texture_creator
.create_text... | {
let sdl_context = sdl2::init()?;
let video_subsystem = sdl_context.video()?;
let window = video_subsystem
.window("SDL2", 640, 480)
.position_centered()
.build()
.map_err(|e| e.to_string())?;
let mut canvas = window
.into_canvas()
.accelerated()
... | identifier_body |
match-pipe-binding.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!(*b, 3);
},
_ => panic!(),
}
}
fn test4() {
match (1, 2, 3) {
(1, a, b) | (2, b, a) if a == 2 => {
assert_eq!(a, 2);
assert_eq!(b, 3);
},
_ => panic!(),
}
}
fn test5() {
match (1, 2, 3) {
(1, ref a, ref b) | ... | (1, ref a, ref b) | (2, ref b, ref a) => {
assert_eq!(*a, 2); | random_line_split |
match-pipe-binding.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 ... | ,
_ => panic!(),
}
}
pub fn main() {
test1();
test2();
test3();
test4();
test5();
}
| {
assert_eq!(*a, 2);
assert_eq!(*b, 3);
} | conditional_block |
match-pipe-binding.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 ... | () {
// from issue 6338
match ((1, "a".to_string()), (2, "b".to_string())) {
((1, a), (2, b)) | ((2, b), (1, a)) => {
assert_eq!(a, "a".to_string());
assert_eq!(b, "b".to_string());
},
_ => panic!(),
}
}
fn test2() {
match (1, 2, 3) {
... | test1 | identifier_name |
match-pipe-binding.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 test3() {
match (1, 2, 3) {
(1, ref a, ref b) | (2, ref b, ref a) => {
assert_eq!(*a, 2);
assert_eq!(*b, 3);
},
_ => panic!(),
}
}
fn test4() {
match (1, 2, 3) {
(1, a, b) | (2, b, a) if a == 2 => {
assert_eq!(a, 2);
asser... | {
match (1, 2, 3) {
(1, a, b) | (2, b, a) => {
assert_eq!(a, 2);
assert_eq!(b, 3);
},
_ => panic!(),
}
} | identifier_body |
traits.rs | // Copyright 2015 The Ramp Developers
//
// 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
// | // Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations und... | // http://www.apache.org/licenses/LICENSE-2.0
// | random_line_split |
states.rs | use std::{cell::RefCell, rc::Rc};
use stdweb::web::event;
/// Used to store and read web events.
pub struct | {
pub mouse_move_events: Rc<RefCell<Vec<event::MouseMoveEvent>>>,
pub mouse_up_events: Rc<RefCell<Vec<event::MouseUpEvent>>>,
pub touch_start_events: Rc<RefCell<Vec<event::TouchStart>>>,
pub touch_end_events: Rc<RefCell<Vec<event::TouchEnd>>>,
pub touch_move_events: Rc<RefCell<Vec<event::TouchMove>... | EventState | identifier_name |
states.rs | use std::{cell::RefCell, rc::Rc};
use stdweb::web::event;
/// Used to store and read web events.
pub struct EventState { | pub touch_start_events: Rc<RefCell<Vec<event::TouchStart>>>,
pub touch_end_events: Rc<RefCell<Vec<event::TouchEnd>>>,
pub touch_move_events: Rc<RefCell<Vec<event::TouchMove>>>,
pub mouse_down_events: Rc<RefCell<Vec<event::MouseDownEvent>>>,
pub scroll_events: Rc<RefCell<Vec<event::MouseWheelEvent>>>... | pub mouse_move_events: Rc<RefCell<Vec<event::MouseMoveEvent>>>,
pub mouse_up_events: Rc<RefCell<Vec<event::MouseUpEvent>>>, | random_line_split |
error.rs | use snafu::Snafu;
/// Represents an error during serialization/deserialization process
#[derive(Debug, Snafu)]
pub enum | {
#[snafu(display("Wrong encoding"))]
WrongEncoding {},
#[snafu(display("{}", source))]
#[snafu(context(false))]
UnknownSpecVersion {
source: crate::event::UnknownSpecVersion,
},
#[snafu(display("Unknown attribute in this spec version: {}", name))]
UnknownAttribute { name: Strin... | Error | identifier_name |
error.rs | use snafu::Snafu;
/// Represents an error during serialization/deserialization process
#[derive(Debug, Snafu)]
pub enum Error {
#[snafu(display("Wrong encoding"))]
WrongEncoding {},
#[snafu(display("{}", source))]
#[snafu(context(false))]
UnknownSpecVersion {
source: crate::event::UnknownSp... | IOError { source: std::io::Error },
#[snafu(display("Other error: {}", source))]
Other {
source: Box<dyn std::error::Error + Send + Sync>,
},
}
/// Result type alias for return values during serialization/deserialization process
pub type Result<T> = std::result::Result<T, Error>; | #[snafu(display("IO Error: {}", source))]
#[snafu(context(false))] | random_line_split |
mod.rs | use byteorder::{BigEndian, WriteBytesExt};
use db;
use std::cmp;
use std::io::Cursor;
pub mod bloomfilter;
#[macro_export]
macro_rules! retry_bound {
($k:expr) => {
if $k < 9 { // special case since formula yields a very loose upper bound for k < 9
$k as u32 // we can always retrieve k element... |
#[inline]
pub fn tree_height(num: u64) -> u32 {
((num + 1) as f64).log2().ceil() as u32
}
#[inline]
pub fn get_index(labels: &[Vec<u8>], label: &[u8]) -> Option<u64> {
match labels.binary_search_by(|probe| label_cmp(&probe[..], label)) {
Ok(i) => Some(i as u64),
Err(_) => None,
}
}
#[i... | {
unsafe {
(&*(l1 as *const [u8] as *const [u64; 4])).cmp(&*(l2 as *const [u8] as *const [u64; 4]))
}
} | identifier_body |
mod.rs | use byteorder::{BigEndian, WriteBytesExt};
use db;
use std::cmp;
use std::io::Cursor;
pub mod bloomfilter;
#[macro_export]
macro_rules! retry_bound {
($k:expr) => {
if $k < 9 { // special case since formula yields a very loose upper bound for k < 9
$k as u32 // we can always retrieve k element... | } else if db::CIPHER_SIZE <= 1024 {
if num < 8 {
1
} else if num < 32768 {
8
} else if num < 131072 {
16
} else {
32
}
} else if num < 32768 {
1
} else {
8
}
} | } | random_line_split |
mod.rs | use byteorder::{BigEndian, WriteBytesExt};
use db;
use std::cmp;
use std::io::Cursor;
pub mod bloomfilter;
#[macro_export]
macro_rules! retry_bound {
($k:expr) => {
if $k < 9 { // special case since formula yields a very loose upper bound for k < 9
$k as u32 // we can always retrieve k element... |
} else if db::CIPHER_SIZE <= 1024 {
if num < 8 {
1
} else if num < 32768 {
8
} else if num < 131072 {
16
} else {
32
}
} else if num < 32768 {
1
} else {
8
}
}
| {
64
} | conditional_block |
mod.rs | use byteorder::{BigEndian, WriteBytesExt};
use db;
use std::cmp;
use std::io::Cursor;
pub mod bloomfilter;
#[macro_export]
macro_rules! retry_bound {
($k:expr) => {
if $k < 9 { // special case since formula yields a very loose upper bound for k < 9
$k as u32 // we can always retrieve k element... | (bucket_len: u64, collection_idx: u32, num_collections: u32) -> u64 {
if num_collections == 1 {
bucket_len
} else if num_collections == 2 {
// hybrid 2
match collection_idx {
0 => (bucket_len as f64 / 2f64).ceil() as u64,
1 => bucket_len / 2,
_ => pani... | collection_len | identifier_name |
mod.rs | //! # Schemes
//! A scheme is a primitive for handling filesystem syscalls in Redox.
//! Schemes accept paths from the kernel for `open`, and file descriptors that they generate
//! are then passed for operations like `close`, `read`, `write`, etc.
//!
//! The kernel validates paths and file descriptors before they are... |
pub fn iter(&self) -> ::collections::btree_map::Iter<usize, Arc<Box<Scheme + Send + Sync>>> {
self.map.iter()
}
pub fn iter_name(&self) -> ::collections::btree_map::Iter<Box<[u8]>, usize> {
self.names.iter()
}
/// Get the nth scheme.
pub fn get(&self, id: usize) -> Option<&Ar... | {
SchemeList {
map: BTreeMap::new(),
names: BTreeMap::new(),
next_id: 1
}
} | identifier_body |
mod.rs | //! # Schemes
//! A scheme is a primitive for handling filesystem syscalls in Redox.
//! Schemes accept paths from the kernel for `open`, and file descriptors that they generate
//! are then passed for operations like `close`, `read`, `write`, etc.
//!
//! The kernel validates paths and file descriptors before they are... | RwLock::new(list)
}
/// Get the global schemes list, const
pub fn schemes() -> RwLockReadGuard<'static, SchemeList> {
SCHEMES.call_once(init_schemes).read()
}
/// Get the global schemes list, mutable
pub fn schemes_mut() -> RwLockWriteGuard<'static, SchemeList> {
SCHEMES.call_once(init_schemes).write()
} | list.insert(Box::new(*b"sys"), Arc::new(Box::new(SysScheme::new()))).expect("failed to insert sys scheme");
list.insert(Box::new(*b"zero"), Arc::new(Box::new(ZeroScheme))).expect("failed to insert zero scheme"); | random_line_split |
mod.rs | //! # Schemes
//! A scheme is a primitive for handling filesystem syscalls in Redox.
//! Schemes accept paths from the kernel for `open`, and file descriptors that they generate
//! are then passed for operations like `close`, `read`, `write`, etc.
//!
//! The kernel validates paths and file descriptors before they are... | (&self, name: &[u8]) -> Option<(usize, &Arc<Box<Scheme + Send + Sync>>)> {
if let Some(&id) = self.names.get(name) {
self.get(id).map(|scheme| (id, scheme))
} else {
None
}
}
/// Create a new scheme.
pub fn insert(&mut self, name: Box<[u8]>, scheme: Arc<Box<S... | get_name | identifier_name |
mod.rs | //! # Schemes
//! A scheme is a primitive for handling filesystem syscalls in Redox.
//! Schemes accept paths from the kernel for `open`, and file descriptors that they generate
//! are then passed for operations like `close`, `read`, `write`, etc.
//!
//! The kernel validates paths and file descriptors before they are... |
if self.next_id >= SCHEME_MAX_SCHEMES {
self.next_id = 1;
}
while self.map.contains_key(&self.next_id) {
self.next_id += 1;
}
if self.next_id >= SCHEME_MAX_SCHEMES {
return Err(Error::new(EAGAIN));
}
let id = self.next_id;
... | {
return Err(Error::new(EEXIST));
} | conditional_block |
issue-60925.rs | // build-fail
// revisions: legacy v0
//[legacy]compile-flags: -Z symbol-mangling-version=legacy
//[v0]compile-flags: -Z symbol-mangling-version=v0
#![feature(rustc_attrs)]
// This test is the same code as in ui/issue-53912.rs but this test checks that the symbol mangling
// fix produces the correct result, where... | () {}
| main | identifier_name |
issue-60925.rs | // build-fail
// revisions: legacy v0
//[legacy]compile-flags: -Z symbol-mangling-version=legacy
//[v0]compile-flags: -Z symbol-mangling-version=v0
#![feature(rustc_attrs)]
// This test is the same code as in ui/issue-53912.rs but this test checks that the symbol mangling
// fix produces the correct result, where... |
fn main() {}
| {
foo::foo();
} | identifier_body |
issue-60925.rs | // build-fail
// revisions: legacy v0
//[legacy]compile-flags: -Z symbol-mangling-version=legacy | #![feature(rustc_attrs)]
// This test is the same code as in ui/issue-53912.rs but this test checks that the symbol mangling
// fix produces the correct result, whereas that test just checks that the reproduction compiles
// successfully and doesn't crash LLVM
fn dummy() {}
mod llvm {
pub(crate) struct Foo;
}
mo... | //[v0]compile-flags: -Z symbol-mangling-version=v0
| random_line_split |
incoming.rs | use ::std::sync::{Arc, RwLock, Mutex};
use ::std::io::ErrorKind;
use ::jedi::{self, Value};
use ::error::{TResult, TError};
use ::sync::{SyncConfig, Syncer};
use ::sync::sync_model::{SyncModel, MemorySaver};
use ::storage::Storage;
use ::rusqlite::NO_PARAMS;
use ::api::{Api, ApiReq};
use ::messaging;
use ::models;
use ... |
/// Holds the state for data going from API -> turtl (incoming sync data),
/// including tracking which sync item's we've seen and which we haven't.
pub struct SyncIncoming {
/// Holds our sync config. Note that this is shared between the sync system
/// and the `Turtl` object in the main thread.
config: ... | {
match jedi::get_opt::<Vec<i64>>(&["sync_ids"], val_with_sync_ids) {
Some(x) => {
let mut db_guard = lock!(turtl.db);
if db_guard.is_some() {
match SyncIncoming::ignore_on_next(db_guard.as_mut().expect("turtl::sync_incoming::ignore_syncs_maybe() -- db is None"), &x) ... | identifier_body |
incoming.rs | use ::std::sync::{Arc, RwLock, Mutex};
use ::std::io::ErrorKind;
use ::jedi::{self, Value};
use ::error::{TResult, TError};
use ::sync::{SyncConfig, Syncer};
use ::sync::sync_model::{SyncModel, MemorySaver};
use ::storage::Storage;
use ::rusqlite::NO_PARAMS;
use ::api::{Api, ApiReq};
use ::messaging;
use ::models;
use ... | model
};
model.run_mem_update(turtl, sync_item.action.clone())?;
Ok(())
}
match sync_item.ty.clone() {
SyncType::User => mem_save::<User>(turtl, sync_item)?,
SyncType::Keychain => mem_save::<KeychainEntry>(turtl, sync_item)?,
... | turtl.find_model_key(&mut model)?;
model.deserialize()?;
} | random_line_split |
incoming.rs | use ::std::sync::{Arc, RwLock, Mutex};
use ::std::io::ErrorKind;
use ::jedi::{self, Value};
use ::error::{TResult, TError};
use ::sync::{SyncConfig, Syncer};
use ::sync::sync_model::{SyncModel, MemorySaver};
use ::storage::Storage;
use ::rusqlite::NO_PARAMS;
use ::api::{Api, ApiReq};
use ::messaging;
use ::models;
use ... | (&mut self, run_version: i64) {
self.run_version = run_version;
}
fn get_run_version(&self) -> i64 {
self.run_version
}
fn init(&mut self) -> TResult<()> {
let sync_id = with_db!{ db, self.db, db.kv_get("sync_id") }?;
let skip_init = {
let config_guard = loc... | set_run_version | identifier_name |
extern-call-deep2.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 ... | ;
}
| {
// Make sure we're on a task with small Rust stacks (main currently
// has a large stack)
do task::spawn {
let result = count(1000u);
info!("result = %?", result);
assert_eq!(result, 1000u);
} | identifier_body |
extern-call-deep2.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 ... |
}
#[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
info!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
// Make sure we're on a task with small Rust stacks (main currently
// has a large stack)
do task::spawn {
let result = count... | {
count(data - 1u) + 1u
} | conditional_block |
extern-call-deep2.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 ... | (n: uint) -> uint {
unsafe {
info!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
// Make sure we're on a task with small Rust stacks (main currently
// has a large stack)
do task::spawn {
let result = count(1000u);
info!("result = %?", result);
... | count | identifier_name |
extern-call-deep2.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 ... | #[fixed_stack_segment] #[inline(never)]
fn count(n: uint) -> uint {
unsafe {
info!("n = %?", n);
rustrt::rust_dbg_call(cb, n)
}
}
pub fn main() {
// Make sure we're on a task with small Rust stacks (main currently
// has a large stack)
do task::spawn {
let result = count(100... | }
}
| random_line_split |
historypack.rs | If a given entry has a parent from another file (a copy)
//! then p1node is the hgid from the other file, and copyfrom is the
//! filepath of the other file.
//!
//!.histidx
//! The index file provides a mapping from filename to the file section in
//! the histpack. In V1 it also contains sub-indexes f... | <'a> {
pack: &'a HistoryPack,
offset: u64,
current_name: RepoPathBuf,
current_remaining: u32,
}
impl<'a> HistoryPackIterator<'a> {
pub fn new(pack: &'a HistoryPack) -> Self {
HistoryPackIterator {
pack,
offset: 1, // Start after the header byte
current_na... | HistoryPackIterator | identifier_name |
historypack.rs | copyfrom is the
//! filepath of the other file.
//!
//!.histidx
//! The index file provides a mapping from filename to the file section in
//! the histpack. In V1 it also contains sub-indexes for specific nodes
//! within each file. It consists of three parts, the fanout, the file index
//! and the... | let path = &mutpack.flush().unwrap().unwrap()[0];
let pack_path = path.with_extension("histpack"); | random_line_split | |
historypack.rs | If a given entry has a parent from another file (a copy)
//! then p1node is the hgid from the other file, and copyfrom is the
//! filepath of the other file.
//!
//!.histidx
//! The index file provides a mapping from filename to the file section in
//! the histpack. In V1 it also contains sub-indexes f... | mmap,
version,
index: HistoryIndex::new(&index_path)?,
base_path: Arc::new(base_path),
pack_path,
index_path,
})
}
pub fn len(&self) -> usize {
self.mmap.len()
}
pub fn base_path(&self) -> &Path {
&self.ba... | {
let base_path = PathBuf::from(path);
let pack_path = path.with_extension("histpack");
let file = File::open(&pack_path)?;
let len = file.metadata()?.len();
if len < 1 {
return Err(format_err!(
"empty histpack '{:?}' is invalid",
path.... | identifier_body |
webglprogram.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use dom::bindings::codegen::Bindings::WebGLPr... | (self) {
if!self.is_deleted.get() {
self.is_deleted.set(true);
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteProgram(self.id))).unwrap();
}
}
/// glLinkProgram
fn link(self) {
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::LinkProgram(self.id... | delete | identifier_name |
webglprogram.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use dom::bindings::codegen::Bindings::WebGLPr... |
let (sender, receiver) = channel();
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetAttribLocation(self.id, name, sender))).unwrap();
Ok(receiver.recv().unwrap())
}
/// glGetUniformLocation
fn get_uniform_location(self, name: String) -> WebGLResult<Option<i32>> {
if... | {
return Ok(None);
} | conditional_block |
webglprogram.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use dom::bindings::codegen::Bindings::WebGLPr... |
/// glUseProgram
fn use_program(self) {
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::UseProgram(self.id))).unwrap();
}
/// glAttachShader
fn attach_shader(self, shader: &WebGLShader) -> WebGLResult<()> {
let shader_slot = match shader.gl_type() {
constants::FRAG... | {
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::LinkProgram(self.id))).unwrap();
} | identifier_body |
webglprogram.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
use dom::bindings::codegen::Bindings::WebGLPr... | /// glDeleteProgram
fn delete(self) {
if!self.is_deleted.get() {
self.is_deleted.set(true);
self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::DeleteProgram(self.id))).unwrap();
}
}
/// glLinkProgram
fn link(self) {
self.renderer.send(CanvasMsg::WebG... | fn get_uniform_location(self, name: String) -> WebGLResult<Option<i32>>;
}
impl<'a> WebGLProgramHelpers for &'a WebGLProgram { | random_line_split |
hash.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... |
}
| {
assert_eq!(hash::H256::from(0), H256(hash::H256::from(0)).into());
} | identifier_body |
hash.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | let mut hex = "0x".to_owned();
hex.push_str(&self.0.to_hex());
serializer.serialize_str(&hex)
}
}
}
}
impl_hash!(H64, Hash64);
impl_hash!(Address, Hash160);
impl_hash!(H256, Hash256);
impl_hash!(H520, Hash520);
impl_hash!(Bloom, Hash2048);
#[cfg(test)]
mod test {
use std::str::FromStr;
use serde_j... |
impl Serialize for $name {
fn serialize<S>(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer { | random_line_split |
hash.rs | // Copyright 2015, 2016 Parity Technologies (UK) Ltd.
// This file is part of Parity.
// Parity is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any la... | () {
assert_eq!(hash::H256::from(0), H256(hash::H256::from(0)).into());
}
}
| hash_into | identifier_name |
read_until.rs | use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use futures_io::AsyncBufRead;
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_until`](super::AsyncBufReadExt::read_until) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.aw... | else {
buf.extend_from_slice(available);
(false, available.len())
}
};
reader.as_mut().consume(used);
*read += used;
if done || used == 0 {
return Poll::Ready(Ok(mem::replace(read, 0)));
}
}
}
impl<R: AsyncBufRead +?Si... | {
buf.extend_from_slice(&available[..=i]);
(true, i + 1)
} | conditional_block |
read_until.rs | use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use futures_io::AsyncBufRead;
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_until`](super::AsyncBufReadExt::read_until) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.aw... | read: usize,
}
impl<R:?Sized + Unpin> Unpin for ReadUntil<'_, R> {}
impl<'a, R: AsyncBufRead +?Sized + Unpin> ReadUntil<'a, R> {
pub(super) fn new(reader: &'a mut R, byte: u8, buf: &'a mut Vec<u8>) -> Self {
Self { reader, byte, buf, read: 0 }
}
}
pub(super) fn read_until_internal<R: AsyncBufRead... | pub struct ReadUntil<'a, R: ?Sized> {
reader: &'a mut R,
byte: u8,
buf: &'a mut Vec<u8>, | random_line_split |
read_until.rs | use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use futures_io::AsyncBufRead;
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_until`](super::AsyncBufReadExt::read_until) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.aw... |
impl<R: AsyncBufRead +?Sized + Unpin> Future for ReadUntil<'_, R> {
type Output = io::Result<usize>;
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
let Self { reader, byte, buf, read } = &mut *self;
read_until_internal(Pin::new(reader), cx, *byte, buf, read)
... | {
loop {
let (done, used) = {
let available = ready!(reader.as_mut().poll_fill_buf(cx))?;
if let Some(i) = memchr::memchr(byte, available) {
buf.extend_from_slice(&available[..=i]);
(true, i + 1)
} else {
buf.extend_from_sli... | identifier_body |
read_until.rs | use futures_core::future::Future;
use futures_core::ready;
use futures_core::task::{Context, Poll};
use futures_io::AsyncBufRead;
use std::io;
use std::mem;
use std::pin::Pin;
/// Future for the [`read_until`](super::AsyncBufReadExt::read_until) method.
#[derive(Debug)]
#[must_use = "futures do nothing unless you `.aw... | <R: AsyncBufRead +?Sized>(
mut reader: Pin<&mut R>,
cx: &mut Context<'_>,
byte: u8,
buf: &mut Vec<u8>,
read: &mut usize,
) -> Poll<io::Result<usize>> {
loop {
let (done, used) = {
let available = ready!(reader.as_mut().poll_fill_buf(cx))?;
if let Some(i) = memchr:... | read_until_internal | identifier_name |
activity.rs | use event::{Event, React};
use failure::Error;
use framework::context::{RenderContextView, State, UpdateContextView};
use framework::FrameworkError;
use render::MetaRenderer;
pub enum Transition<T, R>
where
T: State,
R: MetaRenderer,
{
None,
Push(BoxActivity<T, R>),
Pop,
Abort,
}
impl<T, R> Tr... | pub fn render<C>(&mut self, context: &mut C) -> Result<(), Error>
where
C: RenderContextView<R, State = T>,
{
self.peek_mut().map_or(Ok(()), |activity| {
activity.render(context).map_err(|error| error.into())
})
}
fn peek_mut(&mut self) -> Option<&mut Activity<T,... | random_line_split | |
activity.rs | use event::{Event, React};
use failure::Error;
use framework::context::{RenderContextView, State, UpdateContextView};
use framework::FrameworkError;
use render::MetaRenderer;
pub enum Transition<T, R>
where
T: State,
R: MetaRenderer,
{
None,
Push(BoxActivity<T, R>),
Pop,
Abort,
}
impl<T, R> Tr... | (&mut self) {}
fn stop(&mut self) {}
}
pub struct ActivityStack<T, R>
where
T: State,
R: MetaRenderer,
{
stack: Vec<BoxActivity<T, R>>,
}
impl<T, R> ActivityStack<T, R>
where
T: State,
R: MetaRenderer,
{
pub fn new(activity: BoxActivity<T, R>) -> Self {
ActivityStack {
... | resume | identifier_name |
activity.rs | use event::{Event, React};
use failure::Error;
use framework::context::{RenderContextView, State, UpdateContextView};
use framework::FrameworkError;
use render::MetaRenderer;
pub enum Transition<T, R>
where
T: State,
R: MetaRenderer,
{
None,
Push(BoxActivity<T, R>),
Pop,
Abort,
}
impl<T, R> Tr... |
fn stop(&mut self) {}
}
pub struct ActivityStack<T, R>
where
T: State,
R: MetaRenderer,
{
stack: Vec<BoxActivity<T, R>>,
}
impl<T, R> ActivityStack<T, R>
where
T: State,
R: MetaRenderer,
{
pub fn new(activity: BoxActivity<T, R>) -> Self {
ActivityStack {
stack: vec![ac... | {} | identifier_body |
activity.rs | use event::{Event, React};
use failure::Error;
use framework::context::{RenderContextView, State, UpdateContextView};
use framework::FrameworkError;
use render::MetaRenderer;
pub enum Transition<T, R>
where
T: State,
R: MetaRenderer,
{
None,
Push(BoxActivity<T, R>),
Pop,
Abort,
}
impl<T, R> Tr... |
else {
None
}
}
fn push(&mut self, activity: BoxActivity<T, R>) {
if let Some(activity) = self.peek_mut() {
activity.suspend();
}
self.stack.push(activity);
}
fn pop(&mut self) -> bool {
self.stack
.pop()
.m... | {
// Cannot use `map`.
Some(activity.as_mut())
} | conditional_block |
notify.rs | use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Instant;
use crossbeam_channel::Sender;
use dbus::ffidisp::stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged};
use dbus::ffidisp::{BusType, Connection};
use dbus::message::SignalArgs;
use serde_derive::Deserialize;
use crate::blocks::{... | for msg in c.incoming(1000) {
if let Some(signal) = PropertiesPropertiesChanged::from_message(&msg) {
let value = signal.changed_properties.get("paused").unwrap();
let status = &value.0.as_i64().unwrap();
... | random_line_split | |
notify.rs | use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Instant;
use crossbeam_channel::Sender;
use dbus::ffidisp::stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged};
use dbus::ffidisp::{BusType, Connection};
use dbus::message::SignalArgs;
use serde_derive::Deserialize;
use crate::blocks::{... | (&self) -> Vec<&dyn I3BarWidget> {
vec![&self.output]
}
fn click(&mut self, e: &I3BarEvent) -> Result<()> {
if let MouseButton::Left = e.button {
let c = Connection::get_private(BusType::Session)
.block_error("notify", "Failed to establish D-Bus connection")?;
... | view | identifier_name |
notify.rs | use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Instant;
use crossbeam_channel::Sender;
use dbus::ffidisp::stdintf::org_freedesktop_dbus::{Properties, PropertiesPropertiesChanged};
use dbus::ffidisp::{BusType, Connection};
use dbus::message::SignalArgs;
use serde_derive::Deserialize;
use crate::blocks::{... | else {
p.set("org.dunstproject.cmd0", "paused", true)
.block_error("notify", "Failed to query D-Bus")?;
}
// block will auto-update due to monitoring the bus
}
Ok(())
}
}
| {
p.set("org.dunstproject.cmd0", "paused", false)
.block_error("notify", "Failed to query D-Bus")?;
} | conditional_block |
task-comm-4.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 ... | println!("{}", r);
assert_eq!(sum, 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8);
} | println!("{}", r);
r = rx.recv();
sum += r; | random_line_split |
task-comm-4.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
let mut r: int = 0;
let mut sum: int = 0;
let (tx, rx) = channel();
tx.send(1);
tx.send(2);
tx.send(3);
tx.send(4);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
... | test00 | identifier_name |
task-comm-4.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 ... | tx.send(5);
tx.send(6);
tx.send(7);
tx.send(8);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
assert_eq!(sum, 1 + 2 + 3 + ... | {
let mut r: int = 0;
let mut sum: int = 0;
let (tx, rx) = channel();
tx.send(1);
tx.send(2);
tx.send(3);
tx.send(4);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
r = rx.recv();
sum += r;
println!("{}", r);
r ... | identifier_body |
_common.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 ... | {
let mut out = io::stdout();
let x: f64 = text.parse().unwrap();
let f64_bytes: u64 = unsafe { transmute(x) };
let x: f32 = text.parse().unwrap();
let f32_bytes: u32 = unsafe { transmute(x) };
writeln!(&mut out, "{:016x} {:08x} {}", f64_bytes, f32_bytes, text).unwrap();
} | identifier_body | |
_common.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 ... | (text: &str) {
let mut out = io::stdout();
let x: f64 = text.parse().unwrap();
let f64_bytes: u64 = unsafe { transmute(x) };
let x: f32 = text.parse().unwrap();
let f32_bytes: u32 = unsafe { transmute(x) };
writeln!(&mut out, "{:016x} {:08x} {}", f64_bytes, f32_bytes, text).unwrap();
}
| validate | identifier_name |
_common.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 ... | use std::io;
use std::io::prelude::*;
use std::mem::transmute;
// Nothing up my sleeve: Just (PI - 3) in base 16.
#[allow(dead_code)]
pub const SEED: [u32; 3] = [0x243f_6a88, 0x85a3_08d3, 0x1319_8a2e];
pub fn validate(text: &str) {
let mut out = io::stdout();
let x: f64 = text.parse().unwrap();
let f64_by... | // except according to those terms.
| random_line_split |
hostname.rs | extern crate getopts;
extern crate libc;
use getopts::{optflag, getopts, usage, OptGroup};
use libc::{c_char, c_int, size_t};
use std::io::stdio;
use std::os;
static HOSTNAME_MAX_LENGTH: uint = 256;
extern {
fn gethostname(name: *mut c_char, namelen: size_t) -> c_int;
}
fn main() {
let exit_status = run(os:... | () -> Result<String, String> {
let mut name = String::with_capacity(HOSTNAME_MAX_LENGTH).to_c_str();
let result = unsafe { gethostname(name.as_mut_ptr(), HOSTNAME_MAX_LENGTH as size_t) };
if result == 0 {
Ok(name.to_string())
} else {
Err("Failed to get hostname".to_string())
}
}
f... | get_hostname | identifier_name |
hostname.rs | extern crate getopts;
extern crate libc;
use getopts::{optflag, getopts, usage, OptGroup};
use libc::{c_char, c_int, size_t};
use std::io::stdio;
use std::os;
static HOSTNAME_MAX_LENGTH: uint = 256;
extern {
fn gethostname(name: *mut c_char, namelen: size_t) -> c_int;
}
fn main() {
let exit_status = run(os:... |
fn run(args: Vec<String>) -> int {
let program = &args[0];
let parameters = [
optflag("V", "version", "Print the version number and exit"),
optflag("h", "help", "Print this help message")
];
let options = match getopts(args.tail(), parameters) {
Ok(options) => options,
... | {
let instructions = format!("Usage: {} [options] [HOSTNAME]", program);
usage(instructions.as_slice(), options)
} | identifier_body |
hostname.rs | extern crate getopts;
extern crate libc;
use getopts::{optflag, getopts, usage, OptGroup};
use libc::{c_char, c_int, size_t};
use std::io::stdio;
use std::os;
static HOSTNAME_MAX_LENGTH: uint = 256;
extern {
fn gethostname(name: *mut c_char, namelen: size_t) -> c_int; | os::set_exit_status(exit_status);
}
fn usage_message(program: &String, options: &[OptGroup]) -> String {
let instructions = format!("Usage: {} [options] [HOSTNAME]", program);
usage(instructions.as_slice(), options)
}
fn run(args: Vec<String>) -> int {
let program = &args[0];
let parameters = [
... | }
fn main() {
let exit_status = run(os::args()); | random_line_split |
lib.rs | //! If you want to render templates, see the [`Render`](trait.Render.html)
//! trait.
//!
//! To customise the templating behavior, see the
//! [`TemplateSupport`](trait.TemplateSupport.html) trait.
#![deny(missing_docs)]
#[macro_use]
extern crate nickel;
extern crate mustache;
extern crate rustc_serialize;
use rust... | ///
/// This can be useful if you want to keep a clean directory structure
/// without having to spread that knowledge across your handlers.
///
/// See `examples/adjusted_path.rs` for example usage.
fn adjust_path<'a>(&self, path: &'a Path) -> Cow<'a, Path> {
Cow::Borrowed(path)
}
... | None
}
/// Adjust the path of a template lookup before it gets compiled. | random_line_split |
lib.rs | //! If you want to render templates, see the [`Render`](trait.Render.html)
//! trait.
//!
//! To customise the templating behavior, see the
//! [`TemplateSupport`](trait.TemplateSupport.html) trait.
#![deny(missing_docs)]
#[macro_use]
extern crate nickel;
extern crate mustache;
extern crate rustc_serialize;
use rust... | <'a>(&self, path: &'a Path) -> Cow<'a, Path> {
Cow::Borrowed(path)
}
/// The default layout to use when rendering.
///
/// See `examples/default_layout.rs` for example usage.
fn default_layout(&self) -> Option<Cow<Path>> {
None
}
}
/// Handle template caching through a borrowed... | adjust_layout_path | identifier_name |
lib.rs | //! If you want to render templates, see the [`Render`](trait.Render.html)
//! trait.
//!
//! To customise the templating behavior, see the
//! [`TemplateSupport`](trait.TemplateSupport.html) trait.
#![deny(missing_docs)]
#[macro_use]
extern crate nickel;
extern crate mustache;
extern crate rustc_serialize;
use rust... |
}
/// Handle template caching through a borrowed reference.
pub trait TemplateCache {
/// Handles a cache lookup for a given template.
///
/// # Expected behavior
/// ```not_rust
/// if let Some(template) = cache.get(path) {
/// return handle(template)
/// } else {
/// let temp... | {
None
} | identifier_body |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.