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 |
|---|---|---|---|---|
scheduler.rs | use std::io;
use std::io::prelude::*;
use std::collections::{HashSet, HashMap};
use std::str::FromStr;
use time;
use regex::Regex;
use error::Error;
use error::Error::ErrCronFormat;
pub type SchedulerResult<'a> = Result<Scheduler<'a>, Error>;
#[derive(Debug)]
pub struct Scheduler<'a> {
seconds: &'a str,
min... | }
}
fn parse_intervals_field(inter: &str, min: u32, max: u32) -> Result<HashSet<u32>, Error> {
let mut points = HashSet::new();
let parts: Vec<&str> = inter.split(",").collect();
for part in parts {
let x: Vec<&str> = part.split("/").collect();
let y: Vec<&str> = x[0].split("-").colle... | {
let (second, minute, hour, day, month, weekday) = (t.tm_sec as u32,
t.tm_min as u32,
t.tm_hour as u32,
t.tm_mday as u32,
... | identifier_body |
scheduler.rs | use std::io;
use std::io::prelude::*;
use std::collections::{HashSet, HashMap};
use std::str::FromStr;
use time;
use regex::Regex;
use error::Error;
use error::Error::ErrCronFormat;
pub type SchedulerResult<'a> = Result<Scheduler<'a>, Error>;
#[derive(Debug)]
pub struct Scheduler<'a> {
seconds: &'a str,
min... | (intervals: &'a str) -> SchedulerResult {
let reRes = Regex::new(r"^\s*((\*(/\d+)?)|[0-9-,/]+)(\s+((\*(/\d+)?)|[0-9-,/]+)){4,5}\s*$");
match reRes {
Ok(re) => {
if!re.is_match(intervals) {
return Err(ErrCronFormat(format!("invalid format: {}", intervals))... | new | identifier_name |
scheduler.rs | use std::io;
use std::io::prelude::*;
use std::collections::{HashSet, HashMap};
use std::str::FromStr;
use time;
use regex::Regex;
use error::Error;
use error::Error::ErrCronFormat;
pub type SchedulerResult<'a> = Result<Scheduler<'a>, Error>;
#[derive(Debug)]
pub struct Scheduler<'a> {
seconds: &'a str,
min... | }
#[test]
fn test_parse_intervals() {
assert!(Scheduler::new("*/2 1-8,11 * * *").is_ok());
assert!(Scheduler::new("0 */2 1-8,11 * * *").is_ok());
assert!(Scheduler::new("*/2 1-4,16,11,17 * * *").is_ok());
assert!(Scheduler::new("05 */2 1-8,11 * * * *").is_err());
assert!(Scheduler::new("05 */ 1-8,1... |
Ok(points) | random_line_split |
certificate.rs | //
// Copyright 2021 The Project Oak 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 o... | <T>(
&mut self,
public_key: &PKeyRef<T>,
tee_certificate: Vec<u8>,
) -> anyhow::Result<&mut Self>
where
T: HasPublic,
{
let public_key_hash = get_sha256(&public_key.public_key_to_der()?);
let tee_report = Report::new(&public_key_hash);
let attestation_... | add_tee_extension | identifier_name |
certificate.rs | //
// Copyright 2021 The Project Oak 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 o... |
fn set_version(&mut self, version: i32) -> anyhow::Result<&mut Self> {
self.builder.set_version(version)?;
Ok(self)
}
fn set_serial_number(&mut self, serial_number_size: i32) -> anyhow::Result<&mut Self> {
let serial_number = {
let mut serial = BigNum::new()?;
... | {
let builder = X509::builder()?;
Ok(Self { builder })
} | identifier_body |
certificate.rs | //
// Copyright 2021 The Project Oak 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 o... |
let certificate = builder.build(key_pair)?;
Ok(certificate)
}
/// Generates an X.509 certificate based on the certificate signing `request`.
///
/// `add_tee_extension` indicates whether to add a custom extension containing a TEE report.
pub fn sign_certificate(
&self,
... | {
builder.add_tee_extension(key_pair, tee_certificate)?;
} | conditional_block |
certificate.rs | //
// Copyright 2021 The Project Oak 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 o... | .build(&self.builder.x509v3_context(root_certificate, None))?;
self.builder.append_extension(subject_key_identifier)?;
Ok(self)
}
fn add_subject_alt_name_extension(&mut self) -> anyhow::Result<&mut Self> {
let subject_alt_name = SubjectAlternativeName::new()
.dns(D... | random_line_split | |
print_context.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use PageSetup; | use std::mem;
glib_wrapper! {
pub struct PrintContext(Object<ffi::GtkPrintContext, PrintContextClass>);
match fn {
get_type => || ffi::gtk_print_context_get_type(),
}
}
impl PrintContext {
pub fn create_pango_context(&self) -> Option<pango::Context> {
unsafe {
from_glib_fu... | use cairo;
use ffi;
use glib::translate::*;
use pango;
use std::fmt; | random_line_split |
print_context.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use PageSetup;
use cairo;
use ffi;
use glib::translate::*;
use pango;
use std::fmt;
use std::mem;
glib_wrapper! {
pub struct PrintContext(Object<ffi::GtkPrintContext, PrintConte... |
pub fn get_dpi_y(&self) -> f64 {
unsafe {
ffi::gtk_print_context_get_dpi_y(self.to_glib_none().0)
}
}
pub fn get_hard_margins(&self) -> Option<(f64, f64, f64, f64)> {
unsafe {
let mut top = mem::uninitialized();
let mut bottom = mem::uninitializ... | {
unsafe {
ffi::gtk_print_context_get_dpi_x(self.to_glib_none().0)
}
} | identifier_body |
print_context.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use PageSetup;
use cairo;
use ffi;
use glib::translate::*;
use pango;
use std::fmt;
use std::mem;
glib_wrapper! {
pub struct PrintContext(Object<ffi::GtkPrintContext, PrintConte... | (&self) -> Option<pango::FontMap> {
unsafe {
from_glib_none(ffi::gtk_print_context_get_pango_fontmap(self.to_glib_none().0))
}
}
pub fn get_width(&self) -> f64 {
unsafe {
ffi::gtk_print_context_get_width(self.to_glib_none().0)
}
}
pub fn set_cair... | get_pango_fontmap | identifier_name |
print_context.rs | // This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use PageSetup;
use cairo;
use ffi;
use glib::translate::*;
use pango;
use std::fmt;
use std::mem;
glib_wrapper! {
pub struct PrintContext(Object<ffi::GtkPrintContext, PrintConte... | else { None }
}
}
pub fn get_height(&self) -> f64 {
unsafe {
ffi::gtk_print_context_get_height(self.to_glib_none().0)
}
}
pub fn get_page_setup(&self) -> Option<PageSetup> {
unsafe {
from_glib_none(ffi::gtk_print_context_get_page_setup(self.to_g... | { Some((top, bottom, left, right)) } | conditional_block |
trie.rs | /* Copyright 2017 Joel Pedraza
*
* 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 conditions and the following disclaime... | {
node_type: NodeType,
children: [Node; boggle_util::ALPHABET_SIZE],
child_set: BitSet32,
}
impl Trie {
pub fn new() -> Self {
Trie {
node_type: NodeType::Prefix,
children: Default::default(),
child_set: BitSet32::new(),
}
}
pub fn node_type(&s... | Trie | identifier_name |
trie.rs | /* Copyright 2017 Joel Pedraza
*
* 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 conditions and the following disclaime... | trie: &'a Trie,
iter: IndexIter32<'a>,
}
impl<'a> TrieIterator<'a> {
fn new(trie: &'a Trie) -> TrieIterator<'a> {
TrieIterator {
trie: trie,
iter: trie.child_set.iter_ones(),
}
}
}
impl<'a> Iterator for TrieIterator<'a> {
type Item = (&'a Trie, u8);
fn ... |
pub struct TrieIterator<'a> { | random_line_split |
trie.rs | /* Copyright 2017 Joel Pedraza
*
* 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 conditions and the following disclaime... |
} else {
None
}
}
pub fn iter(&self) -> TrieIterator {
TrieIterator::new(self)
}
}
pub struct TrieIterator<'a> {
trie: &'a Trie,
iter: IndexIter32<'a>,
}
impl<'a> TrieIterator<'a> {
fn new(trie: &'a Trie) -> TrieIterator<'a> {
TrieIterator {
... | {
let rest = &s[1..];
child.cns(rest)
} | conditional_block |
unused-attr.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 ... |
}
}
#[foo] //~ ERROR unused attribute
struct Foo {
#[foo] //~ ERROR unused attribute
a: isize
}
#[foo] //~ ERROR unused attribute
trait Baz {
#[foo] //~ ERROR unused attribute
fn blah();
#[foo] //~ ERROR unused attribute
fn blah2() {}
}
fn main() {}
| {} | conditional_block |
unused-attr.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 ... |
#[foo] //~ ERROR unused attribute
struct Foo {
#[foo] //~ ERROR unused attribute
a: isize
}
#[foo] //~ ERROR unused attribute
trait Baz {
#[foo] //~ ERROR unused attribute
fn blah();
#[foo] //~ ERROR unused attribute
fn blah2() {}
}
fn main() {}
| {
match f {
#[foo] //~ ERROR unused attribute
foo::Foo::Bar => {}
}
} | identifier_body |
unused-attr.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 ... | {
#[foo] //~ ERROR unused attribute
a: isize
}
#[foo] //~ ERROR unused attribute
trait Baz {
#[foo] //~ ERROR unused attribute
fn blah();
#[foo] //~ ERROR unused attribute
fn blah2() {}
}
fn main() {}
| Foo | identifier_name |
unused-attr.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![deny(unused_attr... | // file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
// | random_line_split |
use-from-trait-xc.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
} |
use use_from_trait_xc::Trait::foo; //~ ERROR cannot import from a trait or type implementation
//~^ ERROR failed to resolve import
use use_from_trait_xc::Foo::new; //~ ERROR cannot import from a trait or type implementation
//~^ ERROR failed to resolve import | random_line_split |
use-from-trait-xc.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 ... | {
} | identifier_body | |
use-from-trait-xc.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 ... | () {
}
| main | identifier_name |
layout_collection.rs | extern crate wtftw;
use self::wtftw::config::GeneralConfig;
use self::wtftw::core::stack::Stack;
use self::wtftw::layout::Layout;
use self::wtftw::layout::LayoutMessage;
use self::wtftw::window_system::Rectangle;
use self::wtftw::window_system::Window;
use self::wtftw::window_system::WindowSystem;
pub struct LayoutCo... | }
impl LayoutCollection {
pub fn new(layouts: Vec<Box<Layout>>) -> Box<Layout> {
Box::new(LayoutCollection {
layouts: layouts,
current: 0
})
}
}
impl Layout for LayoutCollection {
fn apply_layout(&mut self, window_system: &WindowSystem, screen: Rectangle, config: &G... | pub current: usize | random_line_split |
layout_collection.rs | extern crate wtftw;
use self::wtftw::config::GeneralConfig;
use self::wtftw::core::stack::Stack;
use self::wtftw::layout::Layout;
use self::wtftw::layout::LayoutMessage;
use self::wtftw::window_system::Rectangle;
use self::wtftw::window_system::Window;
use self::wtftw::window_system::WindowSystem;
pub struct | {
pub layouts: Vec<Box<Layout>>,
pub current: usize
}
impl LayoutCollection {
pub fn new(layouts: Vec<Box<Layout>>) -> Box<Layout> {
Box::new(LayoutCollection {
layouts: layouts,
current: 0
})
}
}
impl Layout for LayoutCollection {
fn apply_layout(&mut self... | LayoutCollection | identifier_name |
layout_collection.rs | extern crate wtftw;
use self::wtftw::config::GeneralConfig;
use self::wtftw::core::stack::Stack;
use self::wtftw::layout::Layout;
use self::wtftw::layout::LayoutMessage;
use self::wtftw::window_system::Rectangle;
use self::wtftw::window_system::Window;
use self::wtftw::window_system::WindowSystem;
pub struct LayoutCo... |
_ => self.layouts[self.current].apply_message(message, window_system, stack,
config)
}
}
fn description(&self) -> String {
self.layouts[self.current].description()
}
fn copy(&self) -> Box<Layout> {
Box::new(LayoutCollection {
current:... | {
self.layouts[self.current].unhook(window_system, stack, config);
self.current = (self.current + (self.layouts.len() - 1)) % self.layouts.len();
true
} | conditional_block |
conversions_tests.rs | use std::convert::TryInto;
use hashing;
use crate::gen::build::bazel::remote::execution::v2 as remexec;
#[test]
fn from_our_digest() {
let our_digest = &hashing::Digest::new(
hashing::Fingerprint::from_hex_string(
"0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff",
)
.unwrap(),
... | let bazel_digest = remexec::Digest {
hash: "0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned(),
size_bytes: 10,
};
let converted: Result<hashing::Digest, String> = (&bazel_digest).try_into();
let want = hashing::Digest::new(
hashing::Fingerprint::from_hex_string(
"012... | random_line_split | |
conversions_tests.rs | use std::convert::TryInto;
use hashing;
use crate::gen::build::bazel::remote::execution::v2 as remexec;
#[test]
fn from_our_digest() |
#[test]
fn from_bazel_digest() {
let bazel_digest = remexec::Digest {
hash: "0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned(),
size_bytes: 10,
};
let converted: Result<hashing::Digest, String> = (&bazel_digest).try_into();
let want = hashing::Digest::new(
hashing::Finge... | {
let our_digest = &hashing::Digest::new(
hashing::Fingerprint::from_hex_string(
"0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff",
)
.unwrap(),
10,
);
let converted: remexec::Digest = our_digest.into();
let want = remexec::Digest {
hash: "0123456789abcdeffedcba9876543... | identifier_body |
conversions_tests.rs | use std::convert::TryInto;
use hashing;
use crate::gen::build::bazel::remote::execution::v2 as remexec;
#[test]
fn from_our_digest() {
let our_digest = &hashing::Digest::new(
hashing::Fingerprint::from_hex_string(
"0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff",
)
.unwrap(),
... | () {
let bazel_digest = remexec::Digest {
hash: "0123456789abcdeffedcba98765432100000000000000000ffffffffffffffff".to_owned(),
size_bytes: 10,
};
let converted: Result<hashing::Digest, String> = (&bazel_digest).try_into();
let want = hashing::Digest::new(
hashing::Fingerprint::from_hex_string(
... | from_bazel_digest | identifier_name |
siphash24.rs | //! `SipHash-2-4`
use ffi;
use libc::c_ulonglong;
use randombytes::randombytes_into;
pub const HASHBYTES: usize = ffi::crypto_shorthash_siphash24_BYTES;
pub const KEYBYTES: usize = ffi::crypto_shorthash_siphash24_KEYBYTES;
/// Digest-structure
#[derive(Copy)]
pub struct Digest(pub [u8; HASHBYTES]);
newtype_clone!(Di... | (b: &mut test::Bencher) {
let k = gen_key();
let ms: Vec<Vec<u8>> = BENCH_SIZES.iter().map(|s| {
randombytes(*s)
}).collect();
b.iter(|| {
for m in ms.iter() {
shorthash(m, &k);
}
});
}
}
| bench_shorthash | identifier_name |
siphash24.rs | //! `SipHash-2-4`
use ffi;
use libc::c_ulonglong;
use randombytes::randombytes_into;
pub const HASHBYTES: usize = ffi::crypto_shorthash_siphash24_BYTES;
pub const KEYBYTES: usize = ffi::crypto_shorthash_siphash24_KEYBYTES;
/// Digest-structure
#[derive(Copy)]
pub struct Digest(pub [u8; HASHBYTES]);
newtype_clone!(Di... | ,[0xea, 0xec, 0xb2, 0xa3, 0x0b, 0x22, 0xa8, 0x7f]
,[0x99, 0x24, 0xa4, 0x3c, 0xc1, 0x31, 0x57, 0x24]
,[0xbd, 0x83, 0x8d, 0x3a, 0xaf, 0xbf, 0x8d, 0xb7]
,[0x0b, 0x1a, 0x2a, 0x32, 0x65, 0xd5, 0x1a, 0xea]
... | ,[0x72, 0xfe, 0x52, 0x97, 0x5a, 0x43, 0x64, 0xee]
,[0x5a, 0x16, 0x45, 0xb2, 0x76, 0xd5, 0x92, 0xa1]
,[0xb2, 0x74, 0xcb, 0x8e, 0xbf, 0x87, 0x87, 0x0a]
,[0x6f, 0x9b, 0xb4, 0x20, 0x3d, 0xe7, 0xb3, 0x81] | random_line_split |
siphash24.rs | //! `SipHash-2-4`
use ffi;
use libc::c_ulonglong;
use randombytes::randombytes_into;
pub const HASHBYTES: usize = ffi::crypto_shorthash_siphash24_BYTES;
pub const KEYBYTES: usize = ffi::crypto_shorthash_siphash24_KEYBYTES;
/// Digest-structure
#[derive(Copy)]
pub struct Digest(pub [u8; HASHBYTES]);
newtype_clone!(Di... |
}
| {
let k = gen_key();
let ms: Vec<Vec<u8>> = BENCH_SIZES.iter().map(|s| {
randombytes(*s)
}).collect();
b.iter(|| {
for m in ms.iter() {
shorthash(m, &k);
}
});
} | identifier_body |
u32.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 ... | } | } | random_line_split |
u32.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 ... |
/// Counts the number of leading zeros. Wraps LLVM's `ctlp` intrinsic.
#[inline(always)]
fn leading_zeros(&self) -> u32 { unsafe { intrinsics::ctlz32(*self as i32) as u32 } }
/// Counts the number of trailing zeros. Wraps LLVM's `cttp` intrinsic.
#[inline(always)]
fn t... | { unsafe { intrinsics::ctpop32(*self as i32) as u32 } } | identifier_body |
u32.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | (&self) -> u32 { unsafe { intrinsics::cttz32(*self as i32) as u32 } }
}
}
| trailing_zeros | identifier_name |
mod.rs |
fn create_plugin_jail(root: &Path, log_failures: bool, seccomp_policy: &Path) -> Result<Minijail> {
// All child jails run in a new user namespace without any users mapped,
// they run as nobody unless otherwise configured.
let mut j = Minijail::new().context("failed to create jail")?;
j.namespace_pid... | {
match e {
MmapError::SystemCallFailed(e) => e,
_ => SysError::new(EINVAL),
}
} | identifier_body | |
mod.rs | has an ID associated with it that exists in an ID space shared by every variant
/// of `PluginObject`. This allows all the objects to be indexed in a single map, and allows for a
/// common destroy method.
///
/// In addition to the destory method, each object may have methods specific to its variant type.
/// These ... |
let res = vcpu_plugin.init(&vcpu);
vcpu_thread_barrier.wait();
if let Err(e) = res {
error!("failed to initialize vcpu {}: {}", cpu_id, e);
} else {
loop {
let mut... | .expect("Failed to set thread id"); | random_line_split |
mod.rs | an ID associated with it that exists in an ID space shared by every variant
/// of `PluginObject`. This allows all the objects to be indexed in a single map, and allows for a
/// common destroy method.
///
/// In addition to the destory method, each object may have methods specific to its variant type.
/// These vari... | {
IoEvent {
evt: Event,
addr: IoeventAddress,
length: u32,
datamatch: u64,
},
Memory {
slot: u32,
length: usize,
},
IrqEvent {
irq_id: u32,
evt: Event,
},
}
impl PluginObject {
fn destroy(self, vm: &mut Vm) -> SysResult<()> {
... | PluginObject | identifier_name |
conversion_from_glib.rs | use super::parameter_ffi_call_out;
use crate::{
analysis::{self, try_from_glib::TryFromGlib},
library,
};
#[derive(Clone, Debug)]
pub struct Mode {
pub typ: library::TypeId,
pub transfer: library::Transfer,
pub is_uninitialized: bool,
pub try_from_glib: TryFromGlib,
}
impl From<¶meter_ffi_... | is_uninitialized: orig.is_uninitialized,
try_from_glib: orig.try_from_glib.clone(),
}
}
}
impl From<&analysis::Parameter> for Mode {
fn from(orig: &analysis::Parameter) -> Mode {
Mode {
typ: orig.lib_par.typ,
transfer: orig.lib_par.transfer,
... | random_line_split | |
conversion_from_glib.rs | use super::parameter_ffi_call_out;
use crate::{
analysis::{self, try_from_glib::TryFromGlib},
library,
};
#[derive(Clone, Debug)]
pub struct | {
pub typ: library::TypeId,
pub transfer: library::Transfer,
pub is_uninitialized: bool,
pub try_from_glib: TryFromGlib,
}
impl From<¶meter_ffi_call_out::Parameter> for Mode {
fn from(orig: ¶meter_ffi_call_out::Parameter) -> Mode {
Mode {
typ: orig.typ,
tran... | Mode | identifier_name |
conversion_from_glib.rs | use super::parameter_ffi_call_out;
use crate::{
analysis::{self, try_from_glib::TryFromGlib},
library,
};
#[derive(Clone, Debug)]
pub struct Mode {
pub typ: library::TypeId,
pub transfer: library::Transfer,
pub is_uninitialized: bool,
pub try_from_glib: TryFromGlib,
}
impl From<¶meter_ffi_... |
}
impl From<&analysis::Parameter> for Mode {
fn from(orig: &analysis::Parameter) -> Mode {
Mode {
typ: orig.lib_par.typ,
transfer: orig.lib_par.transfer,
is_uninitialized: false,
try_from_glib: orig.try_from_glib.clone(),
}
}
}
| {
Mode {
typ: orig.typ,
transfer: orig.transfer,
is_uninitialized: orig.is_uninitialized,
try_from_glib: orig.try_from_glib.clone(),
}
} | identifier_body |
fieldinfo.rs | // GObject Introspection Rust bindings.
// Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the Licen... |
/// Obtain the offset in bits of the field member, this is relative to the
/// beginning of the struct or union.
pub fn get_offset(info: *GIFieldInfo) -> int {
unsafe { g_field_info_get_offset(info) as int }
}
/// Obtain the type of a field as a GITypeInfo.
pub fn get_type(info: *GIFieldInfo) -> *GITypeInfo {
... | {
unsafe { g_field_info_get_size(info) as int }
} | identifier_body |
fieldinfo.rs | // GObject Introspection Rust bindings.
// Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the Licen... | value: *GIArgument) -> GBoolean;
}
/// Obtain the flags for this GIFieldInfo.
pub fn get_flags(info: *GIFieldInfo) -> Option<GIFieldInfoFlags> {
let flag: Option<GIFieldInfoFlags> =
FromPrimitive::from_i32(unsafe { g_field_info_get_flags(info) });
return flag
}
/// Obtai... | mem: GPointer,
value: *GIArgument) -> GBoolean;
fn g_field_info_set_field(info: *GIFieldInfo,
mem: GPointer, | random_line_split |
fieldinfo.rs | // GObject Introspection Rust bindings.
// Copyright (C) 2014 Luis Araujo <araujoc.luisf@gmail.com>
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the Licen... | (info: *GIFieldInfo) -> int {
unsafe { g_field_info_get_offset(info) as int }
}
/// Obtain the type of a field as a GITypeInfo.
pub fn get_type(info: *GIFieldInfo) -> *GITypeInfo {
unsafe { g_field_info_get_type(info) }
}
/// Reads a field identified by a GIFieldInfo from a C structure or union.
pub fn get_fi... | get_offset | identifier_name |
event.rs | // Copyright 2015-2016, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use glib::translate::*;
use gdk_ffi as ffi;
use EventType;
use Window;
glib_wrapper! {
... | impl ::std::ops::Deref for $name {
type Target = ::event::Event;
fn deref(&self) -> &::event::Event {
&self.0
}
}
impl ::std::ops::DerefMut for $name {
fn deref_mut(&mut self) -> &mut ::event::Event {
&mut self.0
... | }
}
| random_line_split |
event.rs | // Copyright 2015-2016, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use glib::translate::*;
use gdk_ffi as ffi;
use EventType;
use Window;
glib_wrapper! {
... | (&self) -> EventType {
self.as_ref().type_
}
/// Returns the associated `Window` if applicable.
pub fn get_window(&self) -> Option<Window> {
unsafe { from_glib_none(self.as_ref().window) }
}
/// Returns whether the event was sent explicitly.
pub fn get_send_event(&self) -> bool... | get_event_type | identifier_name |
event.rs | // Copyright 2015-2016, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use glib::translate::*;
use gdk_ffi as ffi;
use EventType;
use Window;
glib_wrapper! {
... |
/// Returns the associated `Window` if applicable.
pub fn get_window(&self) -> Option<Window> {
unsafe { from_glib_none(self.as_ref().window) }
}
/// Returns whether the event was sent explicitly.
pub fn get_send_event(&self) -> bool {
from_glib(self.as_ref().send_event as i32)
... | {
self.as_ref().type_
} | identifier_body |
aio.rs | //! IGD async API example.
//!
//! It demonstrates how to:
//! * get external IP
//! * add port mappings
//! * remove port mappings
//!
//! If everything works fine, 2 port mappings are added, 1 removed and we're left with single
//! port mapping: External 1234 ---> 4321 Internal
use std::env;
use std::net::SocketAddr... | Ok(ip) => ip,
Err(err) => return println!("Failed to get external IP: {}", err),
};
println!("Our public IP is {}", pub_ip);
if let Err(e) = gateway
.add_port(PortMappingProtocol::TCP, 1234, ip, 120, "rust-igd-async-example")
.await
{
println!("Failed to add port ma... | {
let ip = match env::args().nth(1) {
Some(ip) => ip,
None => {
println!("Local socket address is missing!");
println!("This example requires a socket address representing the local machine and the port to bind to as an argument");
println!("Example: target/debug/... | identifier_body |
aio.rs | //! IGD async API example.
//!
//! It demonstrates how to:
//! * get external IP
//! * add port mappings
//! * remove port mappings
//!
//! If everything works fine, 2 port mappings are added, 1 removed and we're left with single
//! port mapping: External 1234 ---> 4321 Internal
use std::env;
use std::net::SocketAddr... | () {
let ip = match env::args().nth(1) {
Some(ip) => ip,
None => {
println!("Local socket address is missing!");
println!("This example requires a socket address representing the local machine and the port to bind to as an argument");
println!("Example: target/deb... | main | identifier_name |
aio.rs | //! IGD async API example.
//!
//! It demonstrates how to:
//! * get external IP | //! * add port mappings
//! * remove port mappings
//!
//! If everything works fine, 2 port mappings are added, 1 removed and we're left with single
//! port mapping: External 1234 ---> 4321 Internal
use std::env;
use std::net::SocketAddrV4;
use igd::aio::search_gateway;
use igd::PortMappingProtocol;
use simplelog::{... | random_line_split | |
env.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... | pub fn has_vpe(&self) -> bool {
self.base.vpe!= 0
}
pub fn vpe(&self) -> &'static mut vpe::VPE {
unsafe {
intrinsics::transmute(self.base.vpe as usize)
}
}
pub fn load_rbufs(&self) -> arch::rbufs::RBufSpace {
arch::rbufs::RBufSpace::new_with(
... | random_line_split | |
env.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... | (&mut self, sel: Selector) {
self.base.caps = sel as u64;
}
pub fn set_eps(&mut self, eps: u64) {
self.base.eps = eps;
}
pub fn set_rbufs(&mut self, rbufs: &arch::rbufs::RBufSpace) {
self.base.rbuf_cur = rbufs.cur as u64;
self.base.rbuf_end = rbufs.end as u64;
}
... | set_next_sel | identifier_name |
env.rs | /*
* Copyright (C) 2018, Nils Asmussen <nils@os.inf.tu-dresden.de>
* Economic rights: Technische Universitaet Dresden (Germany)
*
* This file is part of M3 (Microkernel-based SysteM for Heterogeneous Manycores).
*
* M3 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Genera... |
pub fn load_mounts(&self) -> MountTable {
if self.base.mounts_len!= 0 {
let slice = unsafe {
util::slice_for(self.base.mounts as *const u64, self.base.mounts_len as usize)
};
MountTable::unserialize(&mut SliceSource::new(slice))
}
else {
... | {
(
// it's initially 0. make sure it's at least the first usable selector
util::max(2 + (EP_COUNT - FIRST_FREE_EP) as Selector, self.base.caps as Selector),
self.base.eps
)
} | identifier_body |
redirect.rs | use rustless::server::header;
use rustless::server::status;
use rustless::{Nesting};
#[test]
fn | () {
let app = app!(|api| {
api.prefix("api");
api.post("redirect_me/:href", |endpoint| {
endpoint.handle(|client, params| {
client.redirect(params.find(&"href".to_string()).unwrap().as_string().unwrap())
})
});
});
let response = call_app!(a... | it_allows_redirect | identifier_name |
redirect.rs | use rustless::server::header;
use rustless::server::status;
use rustless::{Nesting};
#[test]
fn it_allows_redirect() {
let app = app!(|api| {
api.prefix("api");
api.post("redirect_me/:href", |endpoint| {
endpoint.handle(|client, params| {
client.redirect(params.find(&"h... | {
let app = app!(|api| {
api.prefix("api");
api.post("redirect_me/:href", |endpoint| {
endpoint.handle(|client, params| {
client.permanent_redirect(params.find(&"href".to_string()).unwrap().as_string().unwrap())
})
});
});
let response = call... | identifier_body | |
redirect.rs | use rustless::server::header;
use rustless::server::status;
use rustless::{Nesting};
#[test]
fn it_allows_redirect() {
let app = app!(|api| {
api.prefix("api");
api.post("redirect_me/:href", |endpoint| { | });
});
let response = call_app!(app, Post, "http://127.0.0.1:3000/api/redirect_me/google.com").ok().unwrap();
assert_eq!(response.status, status::StatusCode::Found);
let &header::Location(ref location) = response.headers.get::<header::Location>().unwrap();
assert_eq!(location, "google.com"... | endpoint.handle(|client, params| {
client.redirect(params.find(&"href".to_string()).unwrap().as_string().unwrap())
}) | random_line_split |
list.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/. */
//! `list` computed values.
#[cfg(feature = "gecko")]
pub use crate::values::specified::list::ListStyleType;
pub... | lazy_static! {
static ref INITIAL_QUOTES: Arc<Box<[QuotePair]>> = Arc::new(
vec![
QuotePair {
opening: "\u{201c}".to_owned().into_boxed_str(),
closing: "\u{201d}".to_owned().into_boxed_str(),
},
QuotePair {
opening: "\u{2018... | use servo_arc::Arc;
| random_line_split |
list.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/. */
//! `list` computed values.
#[cfg(feature = "gecko")]
pub use crate::values::specified::list::ListStyleType;
pub... |
}
| {
Quotes(INITIAL_QUOTES.clone())
} | identifier_body |
list.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/. */
//! `list` computed values.
#[cfg(feature = "gecko")]
pub use crate::values::specified::list::ListStyleType;
pub... | () -> Quotes {
Quotes(INITIAL_QUOTES.clone())
}
}
| get_initial_value | identifier_name |
mod.rs | // The MIT License (MIT)
// | // in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright noti... | // Copyright (c) 2014 Jeremy Letang
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal | random_line_split |
diagnostic.rs | Note);
}
pub fn span_end_note(&self, sp: Span, msg: &str) {
self.handler.custom_emit(&self.cm, EndSpan(sp), msg, Note);
}
pub fn span_help(&self, sp: Span, msg: &str) {
self.handler.emit(Some((&self.cm, sp)), msg, Help);
}
/// Prints out a message with a suggested edit of the co... |
fn highlight_lines(err: &mut EmitterWriter,
cm: &codemap::CodeMap,
sp: Span,
lvl: Level,
lines: codemap::FileLinesResult)
-> io::Result<()>
{
let lines = match lines {
Ok(lines) => lines,
Err(_) => {
... | }
Ok(())
} | random_line_split |
diagnostic.rs |
}
None => ()
}
try!(write!(&mut dst.dst, "\n"));
Ok(())
}
pub struct EmitterWriter {
dst: Destination,
registry: Option<diagnostics::registry::Registry>
}
enum Destination {
Terminal(Box<term::Terminal<WriterWrapper> + Send>),
Raw(Box<Write + Send>),
}
impl EmitterWriter ... | { Ok(()) } | identifier_body | |
diagnostic.rs |
}
pub fn span_end_note(&self, sp: Span, msg: &str) {
self.handler.custom_emit(&self.cm, EndSpan(sp), msg, Note);
}
pub fn span_help(&self, sp: Span, msg: &str) {
self.handler.emit(Some((&self.cm, sp)), msg, Help);
}
/// Prints out a message with a suggested edit of the code.
... | (dst: &mut EmitterWriter, topic: &str, lvl: Level,
msg: &str, code: Option<&str>) -> io::Result<()> {
if!topic.is_empty() {
try!(write!(&mut dst.dst, "{} ", topic));
}
try!(print_maybe_styled(dst,
&format!("{}: ", lvl.to_string()),
... | print_diagnostic | identifier_name |
diagnostic.rs |
}
pub fn span_end_note(&self, sp: Span, msg: &str) {
self.handler.custom_emit(&self.cm, EndSpan(sp), msg, Note);
}
pub fn span_help(&self, sp: Span, msg: &str) {
self.handler.emit(Some((&self.cm, sp)), msg, Help);
}
/// Prints out a message with a suggested edit of the code.
... |
Ok(())
}
fn highlight_lines(err: &mut EmitterWriter,
cm: &codemap::CodeMap,
sp: Span,
lvl: Level,
lines: codemap::FileLinesResult)
-> io::Result<()>
{
let lines = match lines {
Ok(lines) => lines,
E... | {
let elided_line_num = format!("{}", first_line.line_index + MAX_LINES + 1);
try!(write!(&mut err.dst, "{0:1$} {0:2$} ...\n",
"", fm.name.len(), elided_line_num.len()));
} | conditional_block |
stemmer.rs | use std::sync::Arc;
use stemmer;
pub struct StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
tail: TailTokenStream,
stemmer: Arc<stemmer::Stemmer>,
}
impl<TailTokenStream> TokenStream for StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
fn token(&... |
else {
false
}
}
}
impl<TailTokenStream> StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
fn wrap(stemmer: Arc<stemmer::Stemmer>, tail: TailTokenStream) -> StemmerTokenStream<TailTokenStream> {
StemmerTokenStream {
tail,
... | {
// self.tail.token_mut().term.make_ascii_lowercase();
let new_str = self.stemmer.stem_str(&self.token().term);
true
} | conditional_block |
stemmer.rs | use std::sync::Arc;
use stemmer;
pub struct StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
tail: TailTokenStream,
stemmer: Arc<stemmer::Stemmer>,
}
impl<TailTokenStream> TokenStream for StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
fn token(&... | } | random_line_split | |
stemmer.rs | use std::sync::Arc;
use stemmer;
pub struct StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
tail: TailTokenStream,
stemmer: Arc<stemmer::Stemmer>,
}
impl<TailTokenStream> TokenStream for StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
fn token(&... |
fn token_mut(&mut self) -> &mut Token {
self.tail.token_mut()
}
fn advance(&mut self) -> bool {
if self.tail.advance() {
// self.tail.token_mut().term.make_ascii_lowercase();
let new_str = self.stemmer.stem_str(&self.token().term);
true
}
... | {
self.tail.token()
} | identifier_body |
stemmer.rs | use std::sync::Arc;
use stemmer;
pub struct | <TailTokenStream>
where TailTokenStream: TokenStream {
tail: TailTokenStream,
stemmer: Arc<stemmer::Stemmer>,
}
impl<TailTokenStream> TokenStream for StemmerTokenStream<TailTokenStream>
where TailTokenStream: TokenStream {
fn token(&self) -> &Token {
self.tail.token()
}
fn to... | StemmerTokenStream | identifier_name |
context.rs | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use language_tags::... | <'f>(&self, message: &Message, args: Option<&Args<'f>>) -> String {
let mut output = String::new();
let _ = message.write_message(self, &mut output, args);
output
}
/// Write a message to a stream.
pub fn write<'f>(
&self,
message: &Message,
stream: &mut fmt:... | format | identifier_name |
context.rs | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use language_tags::... |
}
impl Default for Context {
fn default() -> Self {
Context {
language_tag: Default::default(),
placeholder_value: None,
}
}
}
| {
message.write_message(self, stream, args)
} | identifier_body |
context.rs | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use language_tags::... |
/// Write a message to a stream.
pub fn write<'f>(
&self,
message: &Message,
stream: &mut fmt::Write,
args: Option<&Args<'f>>,
) -> fmt::Result {
message.write_message(self, stream, args)
}
}
impl Default for Context {
fn default() -> Self {
Context ... | } | random_line_split |
hint.rs | use std::collections::HashMap;
pub type FieldIndex = usize;
/// Hints given when reading parcels.
#[derive(Clone, Debug, PartialEq)]
pub struct Hints {
pub current_field_index: Option<FieldIndex>,
/// The fields for which a length prefix
/// was already present earlier in the layout.
pub known_field_l... |
// Updates the hints to indicate a field was just read.
#[doc(hidden)]
pub fn next_field(&mut self) {
*self.current_field_index.as_mut()
.expect("cannot increment next field when not in a struct")+= 1;
}
// Sets the length of a variable-sized field b... | {
self.current_field_index = Some(0);
} | identifier_body |
hint.rs | use std::collections::HashMap;
pub type FieldIndex = usize;
/// Hints given when reading parcels.
#[derive(Clone, Debug, PartialEq)]
pub struct Hints {
pub current_field_index: Option<FieldIndex>,
/// The fields for which a length prefix
/// was already present earlier in the layout.
pub known_field_l... |
impl Default for Hints {
fn default() -> Self {
Hints {
current_field_index: None,
known_field_lengths: HashMap::new(),
}
}
}
impl Hints {
/// Gets the length of the field currently being
/// read, if known.
pub fn current_field_length(&self) -> Option<Field... | Bytes,
/// The length prefix stores the total number of elements inside another field.
Elements,
}
| random_line_split |
hint.rs | use std::collections::HashMap;
pub type FieldIndex = usize;
/// Hints given when reading parcels.
#[derive(Clone, Debug, PartialEq)]
pub struct Hints {
pub current_field_index: Option<FieldIndex>,
/// The fields for which a length prefix
/// was already present earlier in the layout.
pub known_field_l... | {
/// The length prefix stores the total number of bytes making up another field.
Bytes,
/// The length prefix stores the total number of elements inside another field.
Elements,
}
impl Default for Hints {
fn default() -> Self {
Hints {
current_field_index: None,
k... | LengthPrefixKind | identifier_name |
refcounted.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/. */
//! A generic, safe mechanism by which DOM objects can be pinned and transferred
//! between tasks (or intra-task ... | info!("attempt to cleanup an unrecognized reflector");
}
}
})
}
}
/// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES
pub unsafe extern fn trace_refcounted_objects(tracer: *mut JSTracer, _data: *mut libc::c_void) {
LIVE_REFERENCES.with(|re... | let TrustedReference(raw_reflectable) = raw_reflectable;
LIVE_REFERENCES.with(|ref r| {
let r = r.borrow();
let live_references = r.as_ref().unwrap();
let mut table = live_references.table.borrow_mut();
match table.entry(raw_reflectable) {
... | identifier_body |
refcounted.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/. */
//! A generic, safe mechanism by which DOM objects can be pinned and transferred
//! between tasks (or intra-task ... | }
pub use self::dummy::LIVE_REFERENCES;
/// A pointer to a Rust DOM object that needs to be destroyed.
pub struct TrustedReference(*const libc::c_void);
unsafe impl Send for TrustedReference {}
/// A safe wrapper around a raw pointer to a DOM object that can be
/// shared among tasks for use in asynchronous operatio... | use std::rc::Rc;
use std::cell::RefCell;
use super::LiveDOMReferences;
thread_local!(pub static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> =
Rc::new(RefCell::new(None))); | random_line_split |
refcounted.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/. */
//! A generic, safe mechanism by which DOM objects can be pinned and transferred
//! between tasks (or intra-task ... | const libc::c_void);
unsafe impl Send for TrustedReference {}
/// A safe wrapper around a raw pointer to a DOM object that can be
/// shared among tasks for use in asynchronous operations. The underlying
/// DOM object is guaranteed to live at least as long as the last outstanding
/// `Trusted<T>` instance.
#[allow_un... | ustedReference(* | identifier_name |
plugins.rs | use crate::{
config::{self},
prelude::*,
};
use neon::{prelude::*, result::Throw};
use std::str::FromStr;
use stencila::{
config::Config,
tokio::sync::MutexGuard,
};
use plugins::{self, Plugin, PluginInstallation, Plugins, PLUGINS};
/// Lock the global plugins store
pub fn lock(cx: &mut FunctionContext... |
/// Install a plugin
pub fn install(mut cx: FunctionContext) -> JsResult<JsString> {
let spec = &cx.argument::<JsString>(0)?.value(&mut cx);
let config = &config::lock(&mut cx)?;
let installs = &installations(&mut cx, 1, config)?;
let aliases = &config.plugins.aliases;
let plugins = &mut *lock(&m... | {
let aliases = &config::lock(&mut cx)?.plugins.aliases;
let plugins = &*lock(&mut cx)?;
to_json(cx, plugins.list_plugins(aliases))
} | identifier_body |
plugins.rs | use crate::{
config::{self},
prelude::*,
};
use neon::{prelude::*, result::Throw};
use std::str::FromStr;
use stencila::{
config::Config,
tokio::sync::MutexGuard,
};
use plugins::{self, Plugin, PluginInstallation, Plugins, PLUGINS};
/// Lock the global plugins store
pub fn lock(cx: &mut FunctionContext... | (
cx: &mut FunctionContext,
position: i32,
config: &Config,
) -> Result<Vec<PluginInstallation>, Throw> {
let arg = cx.argument::<JsArray>(position)?.to_vec(cx)?;
if arg.is_empty() {
Ok(config.plugins.installations.clone())
} else {
let mut installations = Vec::new();
for... | installations | identifier_name |
plugins.rs | use crate::{
config::{self},
prelude::*,
};
use neon::{prelude::*, result::Throw};
use std::str::FromStr;
use stencila::{
config::Config,
tokio::sync::MutexGuard,
};
use plugins::{self, Plugin, PluginInstallation, Plugins, PLUGINS};
/// Lock the global plugins store
pub fn lock(cx: &mut FunctionContext... | {
Ok(_) => to_json(cx, plugins.list_plugins(aliases)),
Err(error) => cx.throw_error(error.to_string()),
}
}
/// Uninstall a plugin
pub fn uninstall(mut cx: FunctionContext) -> JsResult<JsString> {
let alias = &cx.argument::<JsString>(0)?.value(&mut cx);
let aliases = &config::lock(&mut ... | random_line_split | |
mod.rs | // Copyright 2012-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-MI... | #[cfg(windows)] pub use sys::ext as windows;
#[cfg(target_os = "android")] pub mod android;
#[cfg(target_os = "bitrig")] pub mod bitrig;
#[cfg(target_os = "dragonfly")] pub mod dragonfly;
#[cfg(target_os = "freebsd")] pub mod freebsd;
#[cfg(target_os = "ios")] pub mod ios;
#[cfg(target_os = "linux")] ... | #![allow(missing_docs, bad_style)]
#[cfg(unix)] pub use sys::ext as unix; | random_line_split |
persistent_list.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/. */
//! A persistent, thread-safe singly-linked list.
use std::mem;
use std::sync::Arc;
pub struct PersistentList<T>... | (&self) -> PersistentList<T> {
// This establishes the persistent nature of this list: we can clone a list by just cloning
// its head.
PersistentList {
head: self.head.clone(),
length: self.length,
}
}
}
pub struct PersistentListIterator<'a,T> where T: 'a + ... | clone | identifier_name |
persistent_list.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/. */
//! A persistent, thread-safe singly-linked list. |
use std::mem;
use std::sync::Arc;
pub struct PersistentList<T> {
head: PersistentListLink<T>,
length: usize,
}
struct PersistentListEntry<T> {
value: T,
next: PersistentListLink<T>,
}
type PersistentListLink<T> = Option<Arc<PersistentListEntry<T>>>;
impl<T> PersistentList<T> where T: Send + Sync {
... | random_line_split | |
map.rs | #![allow(dead_code)]
#[derive(Debug)] enum | { Apple, Carrot, Potato }
#[derive(Debug)] struct Peeled(Food);
#[derive(Debug)] struct Chopped(Food);
#[derive(Debug)] struct Cooked(Food);
// 削水果皮。如果没有水果,就返回 `None`。
// 否则返回削好皮的水果。
fn peel(food: Option<Food>) -> Option<Peeled> {
match food {
Some(food) => Some(Peeled(food)),
None => None,... | Food | identifier_name |
map.rs | #![allow(dead_code)]
#[derive(Debug)] enum Food { Apple, Carrot, Potato }
#[derive(Debug)] struct Peeled(Food);
#[derive(Debug)] struct Chopped(Food);
#[derive(Debug)] struct Cooked(Food);
// 削水果皮。如果没有水果,就返回 `None`。
// 否则返回削好皮的水果。
fn peel(food: Option<Food>) -> Option<Peeled> {
match food {
Some(food) =>... | Some(Peeled(food)) => Some(Chopped(food)),
None => None,
}
}
// 和前面的检查类似,但是使用 `map()` 来替代 `match`。
fn cook(chopped: Option<Chopped>) -> Option<Cooked> {
chopped.map(|Chopped(food)| Cooked(food))
}
// 另外一种实现,我们可以链式调用 `map()` 来简化上述的流程。
fn process(food: Option<Food>) -> Option<Cooke... | // 和上面一样,我们要在切水果之前确认水果是否已经削皮。
fn chop(peeled: Option<Peeled>) -> Option<Chopped> {
match peeled { | random_line_split |
drawing.rs | /*
* Copyright (c) 2018 Boucher, Antoni <bouanto@zoho.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy,... | x: gen.gen_range(20.0, 500.0),
y: gen.gen_range(20.0, 500.0),
color: RGBA::new(
gen.gen_range(0.0, 1.0),
gen.gen_range(0.0, 1.0),
gen.gen_range(0.0, 1.0),
1.0,
),
vx: gen.gen_range(1.0, 5.0),
... | let mut gen = rand::thread_rng();
Circle { | random_line_split |
drawing.rs | /*
* Copyright (c) 2018 Boucher, Antoni <bouanto@zoho.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy,... | () {
Win::run(()).unwrap();
}
| main | identifier_name |
finally.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 mut i = 0;
(|| {
i = 10;
fail!();
}).finally(|| {
assert!(failing());
assert_eq!(i, 10);
})
}
#[test]
fn test_retval() {
let closure: || -> int = || 10;
let i = closure.finally(|| { });
assert_eq!(i, 10);
}
#[test]
fn test_compact() {
fn do_some... | test_fail | identifier_name |
finally.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 ... |
}
#[test]
fn test_success() {
let mut i = 0;
(|| {
i = 10;
}).finally(|| {
assert!(!failing());
assert_eq!(i, 10);
i = 20;
});
assert_eq!(i, 20);
}
#[test]
#[should_fail]
fn test_fail() {
let mut i = 0;
(|| {
i = 10;
fail!();
}).finally(... | {
(self.dtor)();
} | identifier_body |
finally.rs | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | }
impl<'a,T> Finally<T> for 'a || -> T {
fn finally(&self, dtor: ||) -> T {
let _d = Finallyalizer {
dtor: dtor
};
(*self)()
}
}
finally_fn!(extern "Rust" fn() -> T)
struct Finallyalizer<'a> {
dtor: 'a ||
}
#[unsafe_destructor]
impl<'a> Drop for Finallyalizer<'a> {
... | }
}
} | random_line_split |
const-fields-and-indexing.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 ... | struct K {a: isize, b: isize, c: D}
struct D { d: isize, e: isize }
const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
static m : isize = k.c.e;
pub fn main() {
println!("{}", p);
println!("{}", q);
println!("{}", t);
assert_eq!(p, 3);
assert_eq!(q, 3);
assert_eq!(t, 20);
} | static t : isize = s.b;
| random_line_split |
const-fields-and-indexing.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 ... | { d: isize, e: isize }
const k : K = K {a: 10, b: 20, c: D {d: 30, e: 40}};
static m : isize = k.c.e;
pub fn main() {
println!("{}", p);
println!("{}", q);
println!("{}", t);
assert_eq!(p, 3);
assert_eq!(q, 3);
assert_eq!(t, 20);
}
| D | identifier_name |
uniq-cc.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 v = empty_pointy();
{
let mut vb = v.borrow_mut();
vb.a = p(v);
}
} | identifier_body | |
uniq-cc.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
use std::cell::RefCell;
enum maybe_pointy {
none,
p(@RefCell<Pointy>),
}
struct Pointy {
a : maybe_pointy,
c : Box<int>,
d : proc():Send->(),
}
fn empty_pointy() -> @RefCell<Pointy> {
return @RefCell::new(Pointy {
a : none,
c : box 22,
d : proc() {},
})
}
pub fn ... | #![feature(managed_boxes)] | random_line_split |
uniq-cc.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 ... | () -> @RefCell<Pointy> {
return @RefCell::new(Pointy {
a : none,
c : box 22,
d : proc() {},
})
}
pub fn main() {
let v = empty_pointy();
{
let mut vb = v.borrow_mut();
vb.a = p(v);
}
}
| empty_pointy | identifier_name |
lub.rs | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | <'a>(&'a self) -> Equate<'a, 'tcx> { Equate(self.fields.clone()) }
fn sub<'a>(&'a self) -> Sub<'a, 'tcx> { Sub(self.fields.clone()) }
fn lub<'a>(&'a self) -> Lub<'a, 'tcx> { Lub(self.fields.clone()) }
fn glb<'a>(&'a self) -> Glb<'a, 'tcx> { Glb(self.fields.clone()) }
fn mts(&self, a: &ty::mt<'tcx>, b: ... | equate | identifier_name |
lub.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 ... | return Err(ty::terr_mutability)
}
let m = a.mutbl;
match m {
MutImmutable => {
let t = try!(self.tys(a.ty, b.ty));
Ok(ty::mt {ty: t, mutbl: m})
}
MutMutable => {
let t = try!(self.equate().tys(a.ty,... | random_line_split | |
count.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::Enumerate;
struct | <T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self::Item> {
if self.begin < self.end {
let result = self.begin;
self.begin = self.begin.wrapping_add(1);
Some::<Self::Item>(result)
} els... | A | identifier_name |
count.rs | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::iter::Iterator;
use core::iter::Enumerate;
struct A<T> {
begin: T,
end: T
}
macro_rules! Iterator_impl {
($T:ty) => {
impl Iterator for A<$T> {
type Item = $T;
fn next(&mut self) -> Option<Self::Item> {
if ... | //
// #[inline]
// fn count(self) -> usize {
// self.iter.count()
// }
// }
#[test]
fn count_test1() {
let a: A<T> = A { begin: 10, end: 20 };
let enumerate: Enumerate<A<T>> = a.enumerate();
assert_eq!(enumerate.count(), 10);
}
#[test]
fn count_test2... | // let i = self.count + n;
// self.count = i + 1;
// (i, a)
// })
// } | random_line_split |
test.rs | text
/* this is a
/* nested
block */ comment.
And should stay a comment
even with "strings"
or 42 0x18 0b01011 // blah
or u32 as i16 if impl */
text
/** this is a
/*! nested
block */ doc comment */
text
/// test
/// *test*
/// **test**
/// ***test***
/// _test_
/// __test__
/// __***test***__
/// ___test___
/// # te... |
text
fn do_all_the_work (&mut self, param: &str, mut other_param: u32) -> bool {
announce!("There's no cake");
if!test_subject.under_control() {
text
let list: Vec<item> = some_iterator.map(|elem| elem.dosomething()).collect();
text
let boxed_list... | {
assert!(1 != 2);
text
self.with_something(param, |arg1, arg2| {
text
}, other_param);
} | identifier_body |
test.rs | text
/* this is a
/* nested
block */ comment.
And should stay a comment
even with "strings"
or 42 0x18 0b01011 // blah
or u32 as i16 if impl */
text
/** this is a
/*! nested
block */ doc comment */
text
/// test
/// *test*
/// **test**
/// ***test***
/// _test_
/// __test__
/// __***test***__
/// ___test___
/// # te... |
// const function parameter (#52)
fn foo(bar: *const i32) {
let _ = 1234 as *const u32;
}
// Keywords and known types in wrapper structs (#56)
pub struct Foobar(pub Option<bool>);
pub struct Foobar(pub Test<W=bool>);
pub struct Foobar(pub Test<W==bool>);
pub struct Foobar(pub Test<W = bool>);
struct Test(i32);... | { } | conditional_block |
test.rs | text
/* this is a
/* nested
block */ comment.
And should stay a comment
even with "strings"
or 42 0x18 0b01011 // blah
or u32 as i16 if impl */
text
/** this is a
/*! nested
block */ doc comment */
text
/// test
/// *test*
/// **test**
/// ***test***
/// _test_
/// __test__
/// __***test***__
/// ___test___
/// # te... | (pub Test<W=bool>);
pub struct Foobar(pub Test<W==bool>);
pub struct Foobar(pub Test<W = bool>);
struct Test(i32);
struct Test(String);
struct Test(Vec<i32>);
struct Test(BTreeMap<String, i32>);
// Lifetimes in associated type definitions
trait Foo {
type B: A +'static;
}
// where clause
impl Foo<A, B> where tex... | Foobar | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.