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 |
|---|---|---|---|---|
local-drop-glue.rs | //
// We specify -C incremental here because we want to test the partitioning for
// incremental compilation
// We specify opt-level=0 because `drop_in_place` is `Internal` when optimizing
// compile-flags:-Zprint-mono-items=lazy -Cincremental=tmp/partitioning-tests/local-drop-glue
// compile-flags:-Zinline-in-all-cgus... |
}
//~ MONO_ITEM fn std::ptr::drop_in_place::<Outer> - shim(Some(Outer)) @@ local_drop_glue-fallback.cgu[External]
struct Outer {
_a: Struct,
}
//~ MONO_ITEM fn user @@ local_drop_glue[External]
pub fn user() {
let _ = Outer { _a: Struct { _a: 0 } };
}
pub mod mod1 {
use super::Struct;
//~ MONO_ITEM... | {} | identifier_body |
lib.rs | // Copyright 2017 columnar-rs Developers
//
// Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
// http://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 accordin... | /// # fn main() {
/// let column = <Data as Column>::new();
/// # }
/// ```
pub trait Column<'a> {
/// The type representing the wrapped data in a columnar data layout.
type Output;
/// Construct a new `Columar` with default capacity.
/// # Example
///
/// ```
/// # #[macro_use] extern cra... | random_line_split | |
hold.rs | use std::io::{self, Read, Write};
use crate::BufferRedirect;
/// Hold output until dropped. On drop, the held output is sent to the stdout/stderr.
///
/// Note: This will ignore IO errors when printing held output.
pub struct Hold {
buf_redir: Option<BufferRedirect>,
is_stdout: bool,
}
impl Hold {
/// Hol... | let from = self.buf_redir.take().unwrap().into_inner();
// Ignore errors.
if self.is_stdout {
let stdout = io::stdout();
read_into(from, stdout.lock());
} else {
let stderr = io::stderr();
read_into(from, stderr.lock());
}
}
}
| {
fn read_into<R: Read, W: Write>(mut from: R, mut to: W) {
// TODO: use sendfile?
let mut buf = [0u8; 4096];
loop {
// Ignore errors
match from.read(&mut buf) {
Ok(0) => break,
Ok(size) => {
... | identifier_body |
hold.rs | use std::io::{self, Read, Write};
use crate::BufferRedirect;
/// Hold output until dropped. On drop, the held output is sent to the stdout/stderr.
///
/// Note: This will ignore IO errors when printing held output.
pub struct Hold {
buf_redir: Option<BufferRedirect>,
is_stdout: bool,
}
impl Hold {
/// Hol... | let mut buf = [0u8; 4096];
loop {
// Ignore errors
match from.read(&mut buf) {
Ok(0) => break,
Ok(size) => {
if to.write_all(&buf[..size]).is_err() {
break;
... | fn drop(&mut self) {
fn read_into<R: Read, W: Write>(mut from: R, mut to: W) {
// TODO: use sendfile? | random_line_split |
hold.rs | use std::io::{self, Read, Write};
use crate::BufferRedirect;
/// Hold output until dropped. On drop, the held output is sent to the stdout/stderr.
///
/// Note: This will ignore IO errors when printing held output.
pub struct Hold {
buf_redir: Option<BufferRedirect>,
is_stdout: bool,
}
impl Hold {
/// Hol... | () -> io::Result<Hold> {
Ok(Hold {
buf_redir: Some(BufferRedirect::stdout()?),
is_stdout: true,
})
}
}
impl Drop for Hold {
fn drop(&mut self) {
fn read_into<R: Read, W: Write>(mut from: R, mut to: W) {
// TODO: use sendfile?
let mut buf =... | stdout | identifier_name |
reader.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{
agent_error::ImlAgentError,
daemon_plugins::{get_plugin, DaemonPlugins},
http_comms::{
agent_client::AgentClient,
session::{Se... | {
loop {
match get_delivery(sessions.clone(), agent_client.clone(), ®istry).await {
Ok(_) => continue,
Err(ImlAgentError::Reqwest(e)) => {
warn!("Got a manager read Error {:?}. Will retry in 5 seconds.", e);
sessions.terminate_all_sessions().await?... | identifier_body | |
reader.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{
agent_error::ImlAgentError,
daemon_plugins::{get_plugin, DaemonPlugins},
http_comms::{
agent_client::AgentClient,
session::{Se... |
delay_for(Duration::from_secs(5)).await;
}
Err(e) => return Err(e),
}
}
} | Err(ImlAgentError::Reqwest(e)) => {
warn!("Got a manager read Error {:?}. Will retry in 5 seconds.", e);
sessions.terminate_all_sessions().await?; | random_line_split |
reader.rs | // Copyright (c) 2020 DDN. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
use crate::{
agent_error::ImlAgentError,
daemon_plugins::{get_plugin, DaemonPlugins},
http_comms::{
agent_client::AgentClient,
session::{Se... | (
sessions: Sessions,
agent_client: AgentClient,
registry: DaemonPlugins,
) -> Result<(), ImlAgentError> {
loop {
match get_delivery(sessions.clone(), agent_client.clone(), ®istry).await {
Ok(_) => continue,
Err(ImlAgentError::Reqwest(e)) => {
warn!("Go... | create_reader | identifier_name |
errors.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use error_code::{self, ErrorCode, ErrorCodeExt};
use openssl::error::ErrorStack as CrypterError;
use protobuf::ProtobufError;
use std::io::{Error as IoError, ErrorKind};
use std::{error, result};
/// The error type for encryption.
#[derive(Debug, Fail... | {
#[fail(display = "Other error {}", _0)]
Other(Box<dyn error::Error + Sync + Send>),
#[fail(display = "RocksDB error {}", _0)]
Rocks(String),
#[fail(display = "IO error {}", _0)]
Io(IoError),
#[fail(display = "OpenSSL error {}", _0)]
Crypter(CrypterError),
#[fail(display = "Protobu... | Error | identifier_name |
errors.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use error_code::{self, ErrorCode, ErrorCodeExt};
use openssl::error::ErrorStack as CrypterError;
use protobuf::ProtobufError;
use std::io::{Error as IoError, ErrorKind};
use std::{error, result};
/// The error type for encryption.
#[derive(Debug, Fail... | #[fail(display = "Unknown encryption error")]
UnknownEncryption,
#[fail(display = "Wrong master key error {}", _0)]
WrongMasterKey(Box<dyn error::Error + Sync + Send>),
#[fail(
display = "Both master key failed, current key {}, previous key {}.",
_0, _1
)]
BothMasterKeyFail(
... | Crypter(CrypterError),
#[fail(display = "Protobuf error {}", _0)]
Proto(ProtobufError), | random_line_split |
errors.rs | // Copyright 2020 TiKV Project Authors. Licensed under Apache-2.0.
use error_code::{self, ErrorCode, ErrorCodeExt};
use openssl::error::ErrorStack as CrypterError;
use protobuf::ProtobufError;
use std::io::{Error as IoError, ErrorKind};
use std::{error, result};
/// The error type for encryption.
#[derive(Debug, Fail... |
}
pub type Result<T> = result::Result<T, Error>;
impl ErrorCodeExt for Error {
fn error_code(&self) -> ErrorCode {
match self {
Error::Rocks(_) => error_code::encryption::ROCKS,
Error::Io(_) => error_code::encryption::IO,
Error::Crypter(_) => error_code::encryption::CR... | {
match err {
Error::Io(e) => e,
other => IoError::new(ErrorKind::Other, format!("{}", other)),
}
} | identifier_body |
mem.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/. */
//! APIs for memory profiling.
#![deny(missing_docs)]
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::... |
/// Runs `f()` with memory profiling.
pub fn run_with_memory_reporting<F, M, T, C>(&self, f: F,
reporter_name: String,
channel_for_reporter: C,
msg: M)
whe... | {
if let Err(e) = self.0.send(msg) {
warn!("Error communicating with the memory profiler thread: {}", e);
}
} | identifier_body |
mem.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/. */
//! APIs for memory profiling.
#![deny(missing_docs)]
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::... |
}
/// Runs `f()` with memory profiling.
pub fn run_with_memory_reporting<F, M, T, C>(&self, f: F,
reporter_name: String,
channel_for_reporter: C,
msg: M)
... | {
warn!("Error communicating with the memory profiler thread: {}", e);
} | conditional_block |
mem.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/. */
//! APIs for memory profiling.
#![deny(missing_docs)]
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::... | self.send(ProfilerMsg::RegisterReporter(reporter_name.clone(),
Reporter(reporter_sender)));
f();
self.send(ProfilerMsg::UnregisterReporter(reporter_name));
}
}
/// The various kinds of memory measurement.
///
/// Here "explicit" means explic... | channel_for_reporter.send(msg(request.reports_channel));
})); | random_line_split |
mem.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/. */
//! APIs for memory profiling.
#![deny(missing_docs)]
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::... | <F, M, T, C>(&self, f: F,
reporter_name: String,
channel_for_reporter: C,
msg: M)
where F: FnOnce(),
M: Fn(ReportsChan) -> T + Send +'static,
... | run_with_memory_reporting | identifier_name |
srgb.rs | pub trait Clamp: std::cmp::PartialOrd + Sized {
fn clamp(self, min: Self, max: Self) -> Self {
if self.lt(&min) {
min
} else if self.gt(&max) | else {
self
}
}
}
impl Clamp for f32 {}
pub fn srgb_to_linear(v: f32) -> f32 {
if v < 0.04045 {
v / 12.92
} else {
((v + 0.055) / 1.055).powf(2.4).clamp(0.0, 1.0)
}
}
pub fn linear_to_srgb(v: f32) -> f32 {
if v < 0.0031308 {
v * 12.92
} else {
... | {
max
} | conditional_block |
srgb.rs | pub trait Clamp: std::cmp::PartialOrd + Sized {
fn clamp(self, min: Self, max: Self) -> Self {
if self.lt(&min) {
min
} else if self.gt(&max) {
max
} else {
self
}
}
}
impl Clamp for f32 {}
pub fn srgb_to_linear(v: f32) -> f32 { | v / 12.92
} else {
((v + 0.055) / 1.055).powf(2.4).clamp(0.0, 1.0)
}
}
pub fn linear_to_srgb(v: f32) -> f32 {
if v < 0.0031308 {
v * 12.92
} else {
(1.055 * v.powf(1.0 / 2.4) - 0.055).clamp(0.0, 1.0)
}
} | if v < 0.04045 { | random_line_split |
srgb.rs | pub trait Clamp: std::cmp::PartialOrd + Sized {
fn clamp(self, min: Self, max: Self) -> Self {
if self.lt(&min) {
min
} else if self.gt(&max) {
max
} else {
self
}
}
}
impl Clamp for f32 {}
pub fn srgb_to_linear(v: f32) -> f32 {
if v < 0.... | (v: f32) -> f32 {
if v < 0.0031308 {
v * 12.92
} else {
(1.055 * v.powf(1.0 / 2.4) - 0.055).clamp(0.0, 1.0)
}
}
| linear_to_srgb | identifier_name |
srgb.rs | pub trait Clamp: std::cmp::PartialOrd + Sized {
fn clamp(self, min: Self, max: Self) -> Self {
if self.lt(&min) {
min
} else if self.gt(&max) {
max
} else {
self
}
}
}
impl Clamp for f32 {}
pub fn srgb_to_linear(v: f32) -> f32 {
if v < 0.... | {
if v < 0.0031308 {
v * 12.92
} else {
(1.055 * v.powf(1.0 / 2.4) - 0.055).clamp(0.0, 1.0)
}
} | identifier_body | |
ecdsa_signer_key_manager.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | (&self) -> &'static str {
ECDSA_SIGNER_TYPE_URL
}
fn key_material_type(&self) -> tink_proto::key_data::KeyMaterialType {
tink_proto::key_data::KeyMaterialType::AsymmetricPrivate
}
fn supports_private_keys(&self) -> bool {
true
}
fn public_key_data(
&self,
... | type_url | identifier_name |
ecdsa_signer_key_manager.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... | crate::subtle::validate_ecdsa_params(hash, curve, encoding)?;
Ok(params)
}
/// Validate the given [`EcdsaKeyFormat`](tink_proto::EcdsaKeyFormat) and return
/// the parameters.
fn validate_key_format(
key_format: &tink_proto::EcdsaKeyFormat,
) -> Result<(tink_proto::EcdsaParams, tink_proto::EllipticCurveTyp... | // Check the public key points are on the curve by creating a verifier.
crate::subtle::EcdsaVerifier::new(hash, curve, encoding, &pub_key.x, &pub_key.y)
.map_err(|e| wrap_err("EcdsaVerifierKeyManager: invalid key", e))?; | random_line_split |
ecdsa_signer_key_manager.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
};
let pub_key = tink_proto::EcdsaPublicKey {
version: ECDSA_SIGNER_KEY_VERSION,
params: Some(params),
x: pub_x_data,
y: pub_y_data,
};
let priv_key = tink_proto::EcdsaPrivateKey {
version: ECDSA_SIGNER_KEY_VERSION,
... | {
return Err(format!("EcdsaSignerKeyManager: unsupported curve {:?}", curve).into())
} | conditional_block |
ecdsa_signer_key_manager.rs | // Copyright 2020 The Tink-Rust Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or ag... |
}
/// Validate the given [`EcdsaPrivateKey`](tink_proto::EcdsaPrivateKey) and return
/// the parameters.
fn validate_key(key: &tink_proto::EcdsaPrivateKey) -> Result<tink_proto::EcdsaParams, TinkError> {
tink_core::keyset::validate_key_version(key.version, ECDSA_SIGNER_KEY_VERSION)
.map_err(|e| wrap_err("E... | {
let priv_key = tink_proto::EcdsaPrivateKey::decode(serialized_priv_key)
.map_err(|e| wrap_err("EcdsaSignerKeyManager: invalid private key", e))?;
let mut serialized_pub_key = Vec::new();
priv_key
.public_key
.ok_or_else(|| TinkError::new("EcdsaSignerKeyManag... | identifier_body |
dht22.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... | else {
0.1 * (((buffer[2] as u16) << 8) | buffer[3] as u16) as f32
};
let checksum: u8 = buffer[0] + buffer[1] + buffer[2] + buffer[3];
if checksum!= buffer[4] {
None
} else {
Some(Measurements {
humidity: humidity,
temperature: temperature,
})
}
}
fn w... | {
-0.1 * (((buffer[2] as u16 & 0x7F) << 8) | buffer[3] as u16) as f32
} | conditional_block |
dht22.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... | (&self) -> bool {
if!self.wait_while(Low, 80) {
false
} else if!self.wait_while(High, 100) {
false
} else {
true
}
}
fn wait_while(&self, level: GpioLevel, timeout: usize) -> bool {
for _ in range(0, timeout / 10) {
self.timer.wait_us(10);
if self.gpio.level()!= le... | wait_sync | identifier_name |
dht22.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... |
/// Returns previous sensor measurements or None if synchronization failed.
pub fn read(&self) -> Option<Measurements> {
let buffer: &mut [u8; 5] = &mut [0; 5];
let mut idx: usize = 0;
let mut mask: u8 = 128;
self.gpio.set_direction(Out);
self.gpio.set_low();
self.timer.wait_ms(20);
s... | {
DHT22 {
gpio: gpio,
timer: timer,
}
} | identifier_body |
dht22.rs | // Zinc, the bare metal stack for rust.
// Copyright 2014 Vladimir "farcaller" Pouzanov <farcaller@gmail.com>
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.o... | }
}
fn wait_while(&self, level: GpioLevel, timeout: usize) -> bool {
for _ in range(0, timeout / 10) {
self.timer.wait_us(10);
if self.gpio.level()!= level {
return true;
}
}
false
}
} | } else {
true | random_line_split |
range.rs | use super::Index;
/// A range of values in a vector-like object
#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) struct Range {
/// Starting index
start: Index,
/// Ending index
end: Index,
/// Is this range inclusive? If false, this object represents a half-open
/// range of [start, end), o... | (&self, vector_length: usize) -> Option<(usize, usize)> {
if let Some(start) = self.start.resolve(vector_length) {
if let Some(end) = self.end.resolve(vector_length) {
if end < start {
None
} else if self.inclusive {
Some((start... | bounds | identifier_name |
range.rs | use super::Index;
/// A range of values in a vector-like object
#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) struct Range {
/// Starting index
start: Index,
/// Ending index
end: Index,
/// Is this range inclusive? If false, this object represents a half-open
/// range of [start, end), o... | end,
inclusive: true,
}
}
pub(crate) fn exclusive(start: Index, end: Index) -> Range {
Range {
start,
end,
inclusive: false,
}
}
/// Returns the bounds of this range as a tuple containing:
/// - The starting point ... | random_line_split | |
range.rs | use super::Index;
/// A range of values in a vector-like object
#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) struct Range {
/// Starting index
start: Index,
/// Ending index
end: Index,
/// Is this range inclusive? If false, this object represents a half-open
/// range of [start, end), o... |
pub(crate) fn inclusive(start: Index, end: Index) -> Range {
Range {
start,
end,
inclusive: true,
}
}
pub(crate) fn exclusive(start: Index, end: Index) -> Range {
Range {
start,
end,
inclusive: false,
... | {
Range {
start,
end: Index::new(-1),
inclusive: true,
}
} | identifier_body |
range.rs | use super::Index;
/// A range of values in a vector-like object
#[derive(Debug, PartialEq, Copy, Clone)]
pub(crate) struct Range {
/// Starting index
start: Index,
/// Ending index
end: Index,
/// Is this range inclusive? If false, this object represents a half-open
/// range of [start, end), o... | else {
Some((start, end - start))
}
} else {
None
}
} else {
None
}
}
}
| {
Some((start, end - start + 1))
} | conditional_block |
imagedata.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use core::nonzero::NonZero;
use dom::bindings::codegen::Bindings::ImageDataBinding;
use dom::bindings::codegen::Bi... | (&self, _: *mut JSContext) -> NonZero<*mut JSObject> {
assert!(!self.data.get().is_null());
NonZero::new(self.data.get())
}
}
| Data | identifier_name |
imagedata.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use core::nonzero::NonZero;
use dom::bindings::codegen::Bindings::ImageDataBinding;
use dom::bindings::codegen::Bi... |
pub fn get_size(&self) -> Size2D<i32> {
Size2D::new(self.Width() as i32, self.Height() as i32)
}
}
impl ImageDataMethods for ImageData {
// https://html.spec.whatwg.org/multipage/#dom-imagedata-width
fn Width(&self) -> u32 {
self.width
}
// https://html.spec.whatwg.org/multipa... | }
} | random_line_split |
mod.rs | use std;
use std::slice;
use libc::ptrdiff_t;
use md5 as md5_crate;
use sha1;
use sha2::{Digest, Sha224, Sha256, Sha384, Sha512};
use remacs_macros::lisp_fn;
use crate::{
buffers::{LispBufferOrName, LispBufferRef},
lisp::LispObject,
multibyte::LispStringRef,
remacs_sys::EmacsInt,
remacs_sys::{ex... | .unwrap()
.as_mut_slice()
.copy_from_slice(formatted.as_bytes());
digest
}
include!(concat!(env!("OUT_DIR"), "/crypto_exports.rs"));
| {
let b = buffer_or_name.map_or_else(ThreadState::current_buffer_unchecked, LispBufferRef::from);
let mut ctx = sha1::Sha1::new();
ctx.update(unsafe {
slice::from_raw_parts(b.beg_addr(), (b.gpt_byte() - b.beg_byte()) as usize)
});
if b.gpt_byte() < b.z_byte() {
ctx.update(unsafe {
... | identifier_body |
mod.rs | use std;
use std::slice;
use libc::ptrdiff_t;
use md5 as md5_crate;
use sha1;
use sha2::{Digest, Sha224, Sha256, Sha384, Sha512};
use remacs_macros::lisp_fn;
use crate::{
buffers::{LispBufferOrName, LispBufferRef},
lisp::LispObject,
multibyte::LispStringRef,
remacs_sys::EmacsInt,
remacs_sys::{ex... | object: LispObject,
start: LispObject,
end: LispObject,
coding_system: LispObject,
noerror: LispObject,
) -> LispObject {
_secure_hash(
HashAlg::MD5,
object,
start,
end,
coding_system,
noerror,
Qnil,
)
}
/// Return the secure hash of O... | pub fn md5( | random_line_split |
mod.rs | use std;
use std::slice;
use libc::ptrdiff_t;
use md5 as md5_crate;
use sha1;
use sha2::{Digest, Sha224, Sha256, Sha384, Sha512};
use remacs_macros::lisp_fn;
use crate::{
buffers::{LispBufferOrName, LispBufferRef},
lisp::LispObject,
multibyte::LispStringRef,
remacs_sys::EmacsInt,
remacs_sys::{ex... | (
algorithm: HashAlg,
object: LispObject,
start: LispObject,
end: LispObject,
coding_system: LispObject,
noerror: LispObject,
binary: LispObject,
) -> LispObject {
type HashFn = fn(&[u8], &mut [u8]);
let spec = list!(object, start, end, coding_system, noerror);
let mut start_byt... | _secure_hash | identifier_name |
implementation.rs | use time::{at_utc, Tm, Timespec};
use json::{FromJsonnable, ToJsonnable};
use serde::de::{Error, Type};
use serde_json::value::Value;
use serde_json::error::Error as JsonError;
use serde_json::builder::ObjectBuilder;
impl FromJsonnable for Tm {
// Deserialize via Timespec
fn from_json(json: Value) -> Result<Self, J... |
}
macro_rules! primitive_to_json {
($t:ty, $v:ident, $d:ty) => {
impl ToJsonnable for $t {
fn to_json(&self) -> Value {
Value::$v(self.clone() as $d)
}
}
};
}
macro_rules! primitive_from_json {
($t:ty, $expected:ident, $($v:ident)+) => {
impl FromJsonnable for $t {
fn from_json(json: Value) ->... | {
Value::Array(self.iter().map(|ref elem| elem.to_json()).collect())
} | identifier_body |
implementation.rs | use time::{at_utc, Tm, Timespec};
use json::{FromJsonnable, ToJsonnable};
use serde::de::{Error, Type};
use serde_json::value::Value;
use serde_json::error::Error as JsonError;
use serde_json::builder::ObjectBuilder;
impl FromJsonnable for Tm {
// Deserialize via Timespec
fn from_json(json: Value) -> Result<Self, J... | primitive_to_json!(i16, I64, i64);
primitive_to_json!(i32, I64, i64);
primitive_to_json!(i64, I64, i64);
primitive_to_json!(u8, U64, u64);
primitive_to_json!(u16, U64, u64);
primitive_to_json!(u32, U64, u64);
primitive_to_json!(u64, U64, u64);
primitive_to_json!(f32, F64, f64);
primitive_to_json!(f64, F64, f64);
p... | }
};
}
primitive_to_json!(i8, I64, i64); | random_line_split |
implementation.rs | use time::{at_utc, Tm, Timespec};
use json::{FromJsonnable, ToJsonnable};
use serde::de::{Error, Type};
use serde_json::value::Value;
use serde_json::error::Error as JsonError;
use serde_json::builder::ObjectBuilder;
impl FromJsonnable for Tm {
// Deserialize via Timespec
fn from_json(json: Value) -> Result<Self, J... | (&self) -> Value {
let spec = self.to_timespec();
ObjectBuilder::new().insert("sec", &spec.sec)
.insert("nsec", &spec.nsec)
.build()
}
}
impl<T: FromJsonnable> FromJsonnable for Vec<T> {
fn from_json(json: Value) -> Result<Self, JsonError> {
match json {
Value::Arra... | to_json | identifier_name |
media_queries.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::ascii::AsciiExt;
use cssparser::{Token, Parser, Delimiter};
use geom::size::{Size2D, TypedSize2D};
use p... | {
All, // Always true
MediaType(MediaType),
}
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum MediaType {
Screen,
Print,
Unknown,
}
#[derive(Debug)]
pub struct Device {
pub media_type: MediaType,
pub viewport_size: TypedSize2D<ViewportPx, f32>,
}
impl Device {
pub fn new(media... | MediaQueryType | identifier_name |
media_queries.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::ascii::AsciiExt;
use cssparser::{Token, Parser, Delimiter};
use geom::size::{Size2D, TypedSize2D};
use p... | "max-width" => {
Ok(Expression::Width(Range::Max(try!(specified::Length::parse_non_negative(input)))))
}
_ => Err(())
}
})
}
}
impl MediaQuery {
fn parse(input: &mut Parser) -> Result<MediaQuery, ()> {
let mut expre... | "min-width" => {
Ok(Expression::Width(Range::Min(try!(specified::Length::parse_non_negative(input)))))
}, | random_line_split |
media_queries.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::ascii::AsciiExt;
use cssparser::{Token, Parser, Delimiter};
use geom::size::{Size2D, TypedSize2D};
use p... | }
}
}
impl<T: Ord> Range<T> {
fn evaluate(&self, value: T) -> bool {
match *self {
Range::Min(ref width) => { value >= *width },
Range::Max(ref width) => { value <= *width },
//Range::Eq(ref width) => { value == *width },
}
}
}
/// http://dev.w3... | {
let compute_width = |width| {
match width {
&specified::Length::Absolute(value) => value,
&specified::Length::FontRelative(value) => {
// http://dev.w3.org/csswg/mediaqueries3/#units
// em units are relative to the initial fon... | identifier_body |
new.rs | use std::env;
use cargo::ops;
use cargo::util::{CliResult, Config};
#[derive(Deserialize)]
pub struct Options {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_bin: bool,
flag_lib: bool,
arg_path: String,
flag_name: Option<String>,
flag_vcs: Option<ops::Ve... | config.shell().status("Created", format!("{} `{}` project",
if opts_lib { "library" }
else {"binary (application)"},
arg_path))?;
Ok(())
}
| {
debug!("executing; cmd=cargo-new; args={:?}", env::args().collect::<Vec<_>>());
config.configure(options.flag_verbose,
options.flag_quiet,
&options.flag_color,
options.flag_frozen,
options.flag_locked,
&op... | identifier_body |
new.rs | use std::env;
use cargo::ops;
use cargo::util::{CliResult, Config};
#[derive(Deserialize)]
pub struct | {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_bin: bool,
flag_lib: bool,
arg_path: String,
flag_name: Option<String>,
flag_vcs: Option<ops::VersionControl>,
flag_frozen: bool,
flag_locked: bool,
#[serde(rename = "flag_Z")]
flag_z: Vec<St... | Options | identifier_name |
new.rs | use std::env;
use cargo::ops;
use cargo::util::{CliResult, Config};
#[derive(Deserialize)]
pub struct Options {
flag_verbose: u32,
flag_quiet: Option<bool>,
flag_color: Option<String>,
flag_bin: bool,
flag_lib: bool,
arg_path: String,
flag_name: Option<String>,
flag_vcs: Option<ops::Ve... | --color WHEN Coloring: auto, always, never
--frozen Require Cargo.lock and cache are up to date
--locked Require Cargo.lock is up to date
-Z FLAG... Unstable (nightly-only) flags to Cargo
";
pub fn execute(options: Options, config: &mut Config) -> CliResult {
de... | --bin Use a binary (application) template
--lib Use a library template [default]
--name NAME Set the resulting package name, defaults to the value of <path>
-v, --verbose ... Use verbose output (-vv very verbose/build.rs output)
-q, --quiet No output pri... | random_line_split |
asset.rs | use std::sync::Arc;
use std::borrow::Cow;
use asset::{Mesh, Image};
use entity::{EntityTemplate, Entity, ComponentTemplate};
use client::render::Material;
/// Holds AssetData and the path it was loaded from
#[derive(Debug)]
pub struct Asset {
pub asset_data: AssetData,
pub path: Cow<'static, str>
}
/// The d... | {
Mesh,
Image,
EntityTemplate,
StaticEntity,
ComponentTemplate,
Material
}
impl Asset {
/// Create a new asset from its AssetData and its path
pub fn new(path: Cow<'static, str>, asset_data: AssetData) -> Asset {
Asset {
path: path,
asset_data: asset_dat... | AssetType | identifier_name |
asset.rs | use std::sync::Arc;
use std::borrow::Cow;
use asset::{Mesh, Image};
use entity::{EntityTemplate, Entity, ComponentTemplate};
use client::render::Material;
/// Holds AssetData and the path it was loaded from
#[derive(Debug)]
pub struct Asset {
pub asset_data: AssetData,
pub path: Cow<'static, str>
}
/// The d... |
}
| {
let path_parts: Vec<&str> = path.split(".").collect();
let extension = if path_parts.len() > 1 {
path_parts[path_parts.len() - 1]
} else {
return None;
};
match extension {
"obj" => Some(AssetType::Mesh),
"png" | "jpeg" | "jpg" =>... | identifier_body |
asset.rs | use std::sync::Arc; | use std::borrow::Cow;
use asset::{Mesh, Image};
use entity::{EntityTemplate, Entity, ComponentTemplate};
use client::render::Material;
/// Holds AssetData and the path it was loaded from
#[derive(Debug)]
pub struct Asset {
pub asset_data: AssetData,
pub path: Cow<'static, str>
}
/// The data for the various ... | random_line_split | |
timer.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use base::prelude::*;
use core::{mem};
use cty::{c_int, itimerspec, TFD_TIMER_ABSTIME};
use syscall::{close, timerfd_... | (&mut self) {
if self.owned {
close(self.fd);
}
}
}
impl Into<c_int> for Timer {
fn into(self) -> c_int {
let fd = self.fd;
mem::forget(self);
fd
}
}
impl FdContainer for Timer {
fn is_owned(&self) -> bool {
self.owned
}
fn borrow(&s... | drop | identifier_name |
timer.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use base::prelude::*;
use core::{mem};
use cty::{c_int, itimerspec, TFD_TIMER_ABSTIME};
use syscall::{close, timerfd_... |
}
}
impl Into<c_int> for Timer {
fn into(self) -> c_int {
let fd = self.fd;
mem::forget(self);
fd
}
}
impl FdContainer for Timer {
fn is_owned(&self) -> bool {
self.owned
}
fn borrow(&self) -> c_int {
self.fd
}
fn from_owned(fd: c_int) -> Time... | {
close(self.fd);
} | conditional_block |
timer.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use base::prelude::*;
use core::{mem};
use cty::{c_int, itimerspec, TFD_TIMER_ABSTIME};
use syscall::{close, timerfd_... | } |
fn from_borrowed(fd: c_int) -> Timer {
Timer { fd: fd, owned: false }
} | random_line_split |
timer.rs | // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
use base::prelude::*;
use core::{mem};
use cty::{c_int, itimerspec, TFD_TIMER_ABSTIME};
use syscall::{close, timerfd_... |
/// Sets the timer to expire every `iv` time units.
pub fn interval(&self, iv: Time) -> Result {
let arg = itimerspec {
it_interval: time_to_timespec(iv),
it_value: time_to_timespec(iv),
};
rv!(timerfd_settime(self.fd, 0, &arg, None))
}
/// Sets the tim... | {
let arg = mem::zeroed();
rv!(timerfd_settime(self.fd, 0, &arg, None))
} | identifier_body |
rect.rs | // Copyright 2014 The sdl2-rs 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... | (a: &SDL_Rect, b: &SDL_Rect) -> SDL_bool {
if *a == *b { SDL_TRUE } else { SDL_FALSE }
}
extern "C" {
pub fn SDL_HasIntersection(A: *SDL_Rect, B: *SDL_Rect) -> SDL_bool;
pub fn SDL_IntersectRect(A: *SDL_Rect, B: *SDL_Rect, result: *mut SDL_Rect) -> SDL_bool;
pub fn SDL_UnionRect(A: *SDL_Rect, B: *SDL_R... | SDL_RectEquals | identifier_name |
rect.rs | // Copyright 2014 The sdl2-rs 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... | use libc::c_int;
// SDL_rect.h
#[deriving(Eq)]
pub struct SDL_Point {
pub x: c_int,
pub y: c_int,
}
#[deriving(Eq)]
pub struct SDL_Rect {
pub x: c_int,
pub y: c_int,
pub w: c_int,
pub h: c_int,
}
#[inline]
pub fn SDL_RectEmpty(r: &SDL_Rect) -> SDL_bool {
if (r.w <= 0) || (r.h <= 0) { SDL... | // See the License for the specific language governing permissions and
// limitations under the License.
use ffi::stdinc::{SDL_bool, SDL_TRUE, SDL_FALSE}; | random_line_split |
rect.rs | // Copyright 2014 The sdl2-rs 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
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or a... |
}
extern "C" {
pub fn SDL_HasIntersection(A: *SDL_Rect, B: *SDL_Rect) -> SDL_bool;
pub fn SDL_IntersectRect(A: *SDL_Rect, B: *SDL_Rect, result: *mut SDL_Rect) -> SDL_bool;
pub fn SDL_UnionRect(A: *SDL_Rect, B: *SDL_Rect, result: *mut SDL_Rect);
pub fn SDL_EnclosePoints(points: *SDL_Point, count: c_int... | { SDL_FALSE } | conditional_block |
comm.rs | #![crate_name = "comm"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
use getopts::Options;
use std::cmp::Orde... |
fn ensure_nl(line: &mut String) {
match line.chars().last() {
Some('\n') => (),
_ => line.push_str("\n")
}
}
enum LineReader {
Stdin(Stdin),
FileIn(BufReader<File>)
}
impl LineReader {
fn read_line(&mut self, buf: &mut String) -> io::Result<usize> {
match self {
... | {
let mut s = String::new();
let delim = match opts.opt_str("output-delimiter") {
Some(d) => d.clone(),
None => "\t".to_string(),
};
if col > 1 && !opts.opt_present("1") {
s.push_str(delim.as_ref());
}
if col > 2 && !opts.opt_present("2") {
s.push_str(delim.as_re... | identifier_body |
comm.rs | #![crate_name = "comm"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
use getopts::Options;
use std::cmp::Orde... |
0
}
#[allow(dead_code)]
fn main() {
std::process::exit(uumain(std::env::args().collect()));
} | let mut f1 = open_file(matches.free[0].as_ref()).unwrap();
let mut f2 = open_file(matches.free[1].as_ref()).unwrap();
comm(&mut f1, &mut f2, &matches); | random_line_split |
comm.rs | #![crate_name = "comm"]
/*
* This file is part of the uutils coreutils package.
*
* (c) Michael Gehring <mg@ebfe.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
extern crate getopts;
use getopts::Options;
use std::cmp::Orde... | (col: usize, opts: &getopts::Matches) -> String {
let mut s = String::new();
let delim = match opts.opt_str("output-delimiter") {
Some(d) => d.clone(),
None => "\t".to_string(),
};
if col > 1 &&!opts.opt_present("1") {
s.push_str(delim.as_ref());
}
if col > 2 &&!opts.opt... | mkdelim | identifier_name |
windowing.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/. */
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
use geom::poin... |
pub enum WindowNavigateMsg {
Forward,
Back,
}
/// Events that the windowing system sends to Servo.
pub enum WindowEvent {
/// Sent when no message has arrived.
///
/// FIXME: This is a bogus event and is only used because we don't have the new
/// scheduler integrated with the platform event l... | } | random_line_split |
windowing.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/. */
//! Abstract windowing methods. The concrete implementations of these can be found in `platform/`.
use geom::poin... | {
Forward,
Back,
}
/// Events that the windowing system sends to Servo.
pub enum WindowEvent {
/// Sent when no message has arrived.
///
/// FIXME: This is a bogus event and is only used because we don't have the new
/// scheduler integrated with the platform event loop.
IdleWindowEvent,
... | WindowNavigateMsg | identifier_name |
macros.rs | #[macro_use]
extern crate gfx;
pub use gfx::format as fm;
#[derive(Clone, Debug)]
pub struct Rg16;
gfx_format!(Rg16: R16_G16 = Vec2<Float>);
gfx_defines!{
#[derive(PartialEq)]
vertex Vertex {
_x: i8 = "x",
_y: f32 = "y",
}
vertex Instance {
pos: [f32; 2] = "pos",
c... | cbuf: gfx::RawConstantBuffer,
tex: gfx::RawShaderResource,
target: gfx::RawRenderTarget,
});
fn _test_raw<R, F>(factory: &mut F) -> gfx::PipelineState<R, testraw::Meta> where
R: gfx::Resources,
F: gfx::traits::FactoryExt<R>,
{
let special = gfx::pso::buffer::Element {
format: fm::Format... | random_line_split | |
macros.rs | #[macro_use]
extern crate gfx;
pub use gfx::format as fm;
#[derive(Clone, Debug)]
pub struct Rg16;
gfx_format!(Rg16: R16_G16 = Vec2<Float>);
gfx_defines!{
#[derive(PartialEq)]
vertex Vertex {
_x: i8 = "x",
_y: f32 = "y",
}
vertex Instance {
pos: [f32; 2] = "pos",
c... | <R, F>(factory: &mut F) -> gfx::PipelineState<R, testraw::Meta> where
R: gfx::Resources,
F: gfx::traits::FactoryExt<R>,
{
let special = gfx::pso::buffer::Element {
format: fm::Format(fm::SurfaceType::R32, fm::ChannelType::Float),
offset: 0,
};
let init = testraw::Init {
verte... | _test_raw | identifier_name |
message.rs | use libc::{c_int, size_t, c_void};
use std::mem;
use std::marker::PhantomData;
#[repr(C)]
pub struct nl_msg {
_unused: [u8; 0],
}
#[repr(C)]
pub struct nlmsghdr {
_unused: [u8; 0],
}
#[link(name="nl-3")]
extern "C" {
// Exposed msg functions
fn nlmsg_alloc() -> *const nl_msg;
fn nlmsg_free(msg: *const nl_m... |
}
}
pub fn data_len(msg: &NetlinkMessage) -> i32 {
unsafe { nlmsg_datalen(msg.hdr) }
}
pub fn inherit(msg: &NetlinkMessage) -> NetlinkMessage {
let mptr = unsafe { nlmsg_inherit(msg.hdr) };
NetlinkMessage {
ptr: mptr,
hdr: unsafe { nlmsg_hdr(mptr) }
}
}
pub fn dat... | {
true
} | conditional_block |
message.rs | use libc::{c_int, size_t, c_void};
use std::mem;
use std::marker::PhantomData;
#[repr(C)]
pub struct nl_msg {
_unused: [u8; 0],
}
#[repr(C)]
pub struct nlmsghdr {
_unused: [u8; 0],
}
#[link(name="nl-3")]
extern "C" {
// Exposed msg functions
fn nlmsg_alloc() -> *const nl_msg;
fn nlmsg_free(msg: *const nl_m... |
pub fn set(&mut self, data: &T) {
match self.ptr {
None => {
let p: *const c_void = unsafe{ mem::transmute(data) };
self.ptr = Some( p );
},
_ => return
}
}
pub fn from_vptr(&mut self, data: *const c_void) {
match self.ptr... | {
match self.ptr {
None => None,
Some(vptr) => {
Some( unsafe { mem::transmute(vptr) } )
}
}
} | identifier_body |
message.rs | use libc::{c_int, size_t, c_void};
use std::mem;
use std::marker::PhantomData;
#[repr(C)]
pub struct nl_msg {
_unused: [u8; 0], | }
#[link(name="nl-3")]
extern "C" {
// Exposed msg functions
fn nlmsg_alloc() -> *const nl_msg;
fn nlmsg_free(msg: *const nl_msg);
fn nlmsg_append(msg: *const nl_msg, data: *const c_void, len: size_t, pad: c_int) -> i32;
fn nlmsg_put(msg: *const nl_msg, pid: u32, seq: u32, mtype: c_int, payload: c_int, flags: ... | }
#[repr(C)]
pub struct nlmsghdr {
_unused: [u8; 0], | random_line_split |
message.rs | use libc::{c_int, size_t, c_void};
use std::mem;
use std::marker::PhantomData;
#[repr(C)]
pub struct nl_msg {
_unused: [u8; 0],
}
#[repr(C)]
pub struct nlmsghdr {
_unused: [u8; 0],
}
#[link(name="nl-3")]
extern "C" {
// Exposed msg functions
fn nlmsg_alloc() -> *const nl_msg;
fn nlmsg_free(msg: *const nl_m... | <T>(msg: &mut NetlinkMessage, data: &T, len: u32, pad: i32) -> i32 {
unsafe {
let vptr: *const c_void = mem::transmute(data);
nlmsg_append(msg.ptr, vptr, len as size_t, pad as c_int) as i32
}
}
pub fn put(msg: &mut NetlinkMessage, pid: u32, seq: u32, mtype: i32, payload: i32, flags: i32) -> b... | append | identifier_name |
server.rs | use std::io::IoResult;
use crypto::sha1::Sha1;
use crypto::digest::Digest;
use serialize::base64::{ToBase64, STANDARD};
use std::ascii::AsciiExt;
use time;
use std::io::{Listener, Acceptor};
use std::io::net::tcp::TcpListener;
use std::io::net::tcp::TcpStream;
use http::buffer::BufferedStream;
use std::thread::Thread... | payload: message.payload,
opcode: PongOp
};
try!(pong.send(&mut stream));
},
PongOp => (),
_ => in_sender.send(message).unwrap()
}
}
Ok(())
}
fn s... | break; // as this task dies, this should release the write task above, as well as the task set up in handle_ws_connection, if any
},
PingOp => {
let pong = Message { | random_line_split |
server.rs | use std::io::IoResult;
use crypto::sha1::Sha1;
use crypto::digest::Digest;
use serialize::base64::{ToBase64, STANDARD};
use std::ascii::AsciiExt;
use time;
use std::io::{Listener, Acceptor};
use std::io::net::tcp::TcpListener;
use std::io::net::tcp::TcpStream;
use http::buffer::BufferedStream;
use std::thread::Thread... | continue;
},
Ok(socket) => socket,
};
let child_self = self.clone();
Thread::spawn(move || {
let mut stream = BufferedStream::new(stream);
debug!("accepted connection");
let mut succe... | {
let config = self.get_config();
debug!("About to bind to {}", config.bind_address);
let mut acceptor = match TcpListener::bind((config.bind_address.ip.to_string().as_slice(), config.bind_address.port)).listen() {
Err(err) => {
error!("bind or listen failed :-(: {}",... | identifier_body |
server.rs | use std::io::IoResult;
use crypto::sha1::Sha1;
use crypto::digest::Digest;
use serialize::base64::{ToBase64, STANDARD};
use std::ascii::AsciiExt;
use time;
use std::io::{Listener, Acceptor};
use std::io::net::tcp::TcpListener;
use std::io::net::tcp::TcpStream;
use http::buffer::BufferedStream;
use std::thread::Thread... | (&self, sec_websocket_key: &str) -> String {
// NOTE from RFC 6455
//
// To prove that the handshake was received, the server has to take two
// pieces of information and combine them to form a response. The first
// piece of information comes from the |Sec-WebSocket-Key| header... | sec_websocket_accept | identifier_name |
gametime.rs | extern crate time;
|
#[allow(dead_code)]
impl GameTime {
pub fn new() -> GameTime {
let now = time::get_time();
GameTime {
prev_frame_time: now,
curr_frame_time: now,
}
}
pub fn reset(&mut self) {
let now = time::get_time();
self.prev_frame_time = now;
se... | #[derive(Debug, Clone, Copy)]
pub struct GameTime {
prev_frame_time: time::Timespec,
curr_frame_time: time::Timespec,
} | random_line_split |
gametime.rs | extern crate time;
#[derive(Debug, Clone, Copy)]
pub struct GameTime {
prev_frame_time: time::Timespec,
curr_frame_time: time::Timespec,
}
#[allow(dead_code)]
impl GameTime {
pub fn new() -> GameTime {
let now = time::get_time();
GameTime {
prev_frame_time: now,
cur... | (self) -> time::Duration {
self.curr_frame_time - self.prev_frame_time
}
pub fn dt(self) -> f32 {
(self.delta().num_nanoseconds().unwrap() as f32) / 1_000_000_000_f32
}
} | delta | identifier_name |
gametime.rs | extern crate time;
#[derive(Debug, Clone, Copy)]
pub struct GameTime {
prev_frame_time: time::Timespec,
curr_frame_time: time::Timespec,
}
#[allow(dead_code)]
impl GameTime {
pub fn new() -> GameTime {
let now = time::get_time();
GameTime {
prev_frame_time: now,
cur... |
pub fn delta(self) -> time::Duration {
self.curr_frame_time - self.prev_frame_time
}
pub fn dt(self) -> f32 {
(self.delta().num_nanoseconds().unwrap() as f32) / 1_000_000_000_f32
}
} | {
self.prev_frame_time = self.curr_frame_time;
self.curr_frame_time = time::get_time();
} | identifier_body |
capabilities.rs | use caps::*;
use oci::{LinuxCapabilities, LinuxCapabilityType};
fn to_cap(cap: LinuxCapabilityType) -> Capability {
unsafe { ::std::mem::transmute(cap) }
}
fn to_set(caps: &[LinuxCapabilityType]) -> CapsHashSet {
let mut capabilities = CapsHashSet::new();
for c in caps {
capabilities.insert(to_cap... |
pub fn reset_effective() -> ::Result<()> {
let mut all = CapsHashSet::new();
for c in Capability::iter_variants() {
all.insert(c);
}
set(None, CapSet::Effective, all)?;
Ok(())
}
pub fn drop_privileges(cs: &LinuxCapabilities) -> ::Result<()> {
let mut all = CapsHashSet::new();
for c... | capabilities
} | random_line_split |
capabilities.rs | use caps::*;
use oci::{LinuxCapabilities, LinuxCapabilityType};
fn to_cap(cap: LinuxCapabilityType) -> Capability {
unsafe { ::std::mem::transmute(cap) }
}
fn to_set(caps: &[LinuxCapabilityType]) -> CapsHashSet {
let mut capabilities = CapsHashSet::new();
for c in caps {
capabilities.insert(to_cap... | () -> ::Result<()> {
let mut all = CapsHashSet::new();
for c in Capability::iter_variants() {
all.insert(c);
}
set(None, CapSet::Effective, all)?;
Ok(())
}
pub fn drop_privileges(cs: &LinuxCapabilities) -> ::Result<()> {
let mut all = CapsHashSet::new();
for c in Capability::iter_va... | reset_effective | identifier_name |
capabilities.rs | use caps::*;
use oci::{LinuxCapabilities, LinuxCapabilityType};
fn to_cap(cap: LinuxCapabilityType) -> Capability {
unsafe { ::std::mem::transmute(cap) }
}
fn to_set(caps: &[LinuxCapabilityType]) -> CapsHashSet {
let mut capabilities = CapsHashSet::new();
for c in caps {
capabilities.insert(to_cap... | {
let mut all = CapsHashSet::new();
for c in Capability::iter_variants() {
all.insert(c);
}
debug!("dropping bounding capabilities to {:?}", cs.bounding);
// drop excluded caps from the bounding set
for c in all.difference(&to_set(&cs.bounding)) {
drop(None, CapSet::Bounding, *c)... | identifier_body | |
issue-15149.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 ... | fs::copy(&me, &dest).unwrap();
// Append the temp directory to our own PATH.
let mut path = os::split_paths(os::getenv("PATH").unwrap_or(String::new()));
path.push(dir.path().clone());
let path = os::join_paths(path.as_slice()).unwrap();
Command::new("mytest").env("PATH", path.as_slice())
... | let me = os::self_exe_name().unwrap();
let dest = dir.path().join(format!("mytest{}", os::consts::EXE_SUFFIX)); | random_line_split |
issue-15149.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 ... | {
// If we're the parent, copy our own binary to a tempr directory, and then
// make it executable.
let dir = TempDir::new("mytest").unwrap();
let me = os::self_exe_name().unwrap();
let dest = dir.path().join(format!("mytest{}", os::consts::EXE_SUFFIX));
fs::copy(&me, &dest).unwrap();
// Ap... | identifier_body | |
issue-15149.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 ... |
test();
}
fn test() {
// If we're the parent, copy our own binary to a tempr directory, and then
// make it executable.
let dir = TempDir::new("mytest").unwrap();
let me = os::self_exe_name().unwrap();
let dest = dir.path().join(format!("mytest{}", os::consts::EXE_SUFFIX));
fs::copy(&me, ... | {
return assert_eq!(args[0].as_slice(), "mytest");
} | conditional_block |
issue-15149.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 ... | () {
// If we're the child, make sure we were invoked correctly
let args = os::args();
if args.len() > 1 && args[1].as_slice() == "child" {
return assert_eq!(args[0].as_slice(), "mytest");
}
test();
}
fn test() {
// If we're the parent, copy our own binary to a tempr directory, and the... | main | identifier_name |
main.rs | {
version: String,
name: String,
// path to the extracted sources that clippy can check
path: PathBuf,
options: Option<Vec<String>>,
}
/// A single warning that clippy issued while checking a `Crate`
#[derive(Debug)]
struct ClippyWarning {
crate_name: String,
crate_version: String,
fil... | Crate | identifier_name | |
main.rs | },
CrateSource::Git {
name,
url,
commit,
options,
} => {
let repo_path = {
let mut repo_path = PathBuf::from(LINTCHECK_SOURCES);
// add a -git suffix in case we have the sam... | else {
args.extend(&["-Wclippy::pedantic", "-Wclippy::cargo"])
}
let all_output = std::process::Command::new(&cargo_clippy_path)
// use the looping index to create individual target dirs
.env(
"CARGO_TARGET_DIR",
shared_target_dir.join... | {
for opt in options {
args.push(opt);
}
} | conditional_block |
main.rs | },
CrateSource::Git {
name,
url,
commit,
options,
} => {
let repo_path = {
let mut repo_path = PathBuf::from(LINTCHECK_SOURCES);
// add a -git suffix in case we have the sa... | if tk.versions.is_some() && (tk.git_url.is_some() || tk.git_hash.is_some())
|| tk.git_hash.is_some()!= tk.git_url.is_some()
{
eprintln!("tomlkrate: {:?}", tk);
if tk.git_hash.is_some()!= tk.git_url.is_some() {
panic!("Error: Encountered TomlCrate with ... | // if we have a version as well as a git data OR only one git data, something is funky | random_line_split |
helpers.rs | mod pkg_path_for;
mod str_concat;
mod str_join;
mod str_replace;
mod to_json;
mod to_lowercase;
mod to_toml;
mod to_uppercase;
mod to_yaml;
pub use self::{each_alive::EACH_ALIVE,
pkg_path_for::PKG_PATH_FOR,
str_concat::STR_CONCAT,
str_join::STR_JOIN,
str_repl... | mod each_alive; | random_line_split | |
helpers.rs | mod each_alive;
mod pkg_path_for;
mod str_concat;
mod str_join;
mod str_replace;
mod to_json;
mod to_lowercase;
mod to_toml;
mod to_uppercase;
mod to_yaml;
pub use self::{each_alive::EACH_ALIVE,
pkg_path_for::PKG_PATH_FOR,
str_concat::STR_CONCAT,
str_join::STR_JOIN,
... | <T>(src: &T) -> Json
where T: Serialize
{
serde_json::to_value(src).unwrap_or(Json::Null)
}
| to_json | identifier_name |
helpers.rs | mod each_alive;
mod pkg_path_for;
mod str_concat;
mod str_join;
mod str_replace;
mod to_json;
mod to_lowercase;
mod to_toml;
mod to_uppercase;
mod to_yaml;
pub use self::{each_alive::EACH_ALIVE,
pkg_path_for::PKG_PATH_FOR,
str_concat::STR_CONCAT,
str_join::STR_JOIN,
... | {
serde_json::to_value(src).unwrap_or(Json::Null)
} | identifier_body | |
regions-outlives-projection-container-wc.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 ... | pub struct TheType<'b> {
m: [fn(&'b()); 0]
}
impl<'b> TheTrait for TheType<'b> {
type TheAssocType = &'b ();
}
///////////////////////////////////////////////////////////////////////////
pub struct WithAssoc<T> where T : TheTrait {
m: [T; 0]
}
fn with_assoc<'a,'b>() {
// For this type to be valid, t... | type TheAssocType;
}
| random_line_split |
regions-outlives-projection-container-wc.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
fn main() {
}
| {
// For this type to be valid, the rules require that all
// associated types of traits that appear in `WithAssoc` must
// outlive 'a. In this case, that means TheType<'b>::TheAssocType,
// which is &'b (), must outlive 'a.
let _: &'a WithAssoc<TheType<'b>> = loop { };
//~^ ERROR reference has... | identifier_body |
regions-outlives-projection-container-wc.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {
}
| main | identifier_name |
check.rs | use crate::gen::Opt;
use crate::syntax::report::Errors;
use crate::syntax::{error, Api};
use quote::{quote, quote_spanned};
use std::path::{Component, Path};
pub(super) use crate::syntax::check::{typecheck, Generator};
pub(super) fn precheck(cx: &mut Errors, apis: &[Api], opt: &Opt) {
if!opt.allow_dot_includes {
... | let end = quote_spanned!(include.end_span=>.);
let span = quote!(#begin #end);
cx.error(span, error::DOT_INCLUDE.msg);
}
}
}
} | let begin = quote_spanned!(include.begin_span=> .); | random_line_split |
check.rs | use crate::gen::Opt;
use crate::syntax::report::Errors;
use crate::syntax::{error, Api};
use quote::{quote, quote_spanned};
use std::path::{Component, Path};
pub(super) use crate::syntax::check::{typecheck, Generator};
pub(super) fn precheck(cx: &mut Errors, apis: &[Api], opt: &Opt) {
if!opt.allow_dot_includes {
... | {
for api in apis {
if let Api::Include(include) = api {
let first_component = Path::new(&include.path).components().next();
if let Some(Component::CurDir) | Some(Component::ParentDir) = first_component {
let begin = quote_spanned!(include.begin_span=> .);
... | identifier_body | |
check.rs | use crate::gen::Opt;
use crate::syntax::report::Errors;
use crate::syntax::{error, Api};
use quote::{quote, quote_spanned};
use std::path::{Component, Path};
pub(super) use crate::syntax::check::{typecheck, Generator};
pub(super) fn precheck(cx: &mut Errors, apis: &[Api], opt: &Opt) {
if!opt.allow_dot_includes {
... |
}
}
| {
let first_component = Path::new(&include.path).components().next();
if let Some(Component::CurDir) | Some(Component::ParentDir) = first_component {
let begin = quote_spanned!(include.begin_span=> .);
let end = quote_spanned!(include.end_span=> .);
... | conditional_block |
check.rs | use crate::gen::Opt;
use crate::syntax::report::Errors;
use crate::syntax::{error, Api};
use quote::{quote, quote_spanned};
use std::path::{Component, Path};
pub(super) use crate::syntax::check::{typecheck, Generator};
pub(super) fn precheck(cx: &mut Errors, apis: &[Api], opt: &Opt) {
if!opt.allow_dot_includes {
... | (cx: &mut Errors, apis: &[Api]) {
for api in apis {
if let Api::Include(include) = api {
let first_component = Path::new(&include.path).components().next();
if let Some(Component::CurDir) | Some(Component::ParentDir) = first_component {
let begin = quote_spanned!(incl... | check_dot_includes | identifier_name |
indexer.rs | // Copyright (C) 2013-2020 Blockstack PBC, a public benefit corporation | // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// M... | // Copyright (C) 2020 Stacks Open Internet Foundation
//
// This program is free software: you can redistribute it and/or modify | random_line_split |
enum.rs | enum Opaque {
Foo(i32),
Bar,
}
#[repr(u64)]
enum A {
a1 = 0,
a2 = 2,
a3,
a4 = 5,
}
#[repr(u32)]
enum B {
b1 = 0,
b2 = 2,
b3,
b4 = 5,
}
#[repr(u16)]
enum C {
c1 = 0,
c2 = 2,
c3,
c4 = 5,
}
#[repr(u8)]
enum D {
d1 = 0,
d2 = 2,
d3,
d4 = 5,
}
#[rep... | {
m1 = -1,
m2 = 0,
m3 = 1,
}
/// cbindgen:enum-class=false
#[repr(C)]
enum N {
n1,
n2,
n3,
n4,
}
/// cbindgen:enum-class=false
#[repr(i8)]
enum O {
o1,
o2,
o3,
o4,
}
#[repr(C, u8)]
enum P {
P0(u8),
P1(u8, u8, u8),
}
#[no_mangle]
pub extern "C" fn root(
opaque... | M | identifier_name |
enum.rs | enum Opaque {
Foo(i32),
Bar,
}
#[repr(u64)]
enum A {
a1 = 0,
a2 = 2,
a3,
a4 = 5,
}
#[repr(u32)]
enum B {
b1 = 0,
b2 = 2,
b3,
b4 = 5,
}
#[repr(u16)]
enum C {
c1 = 0,
c2 = 2, | enum D {
d1 = 0,
d2 = 2,
d3,
d4 = 5,
}
#[repr(usize)]
enum E {
e1 = 0,
e2 = 2,
e3,
e4 = 5,
}
#[repr(isize)]
enum F {
f1 = 0,
f2 = 2,
f3,
f4 = 5,
}
#[repr(u8)]
enum G {
Foo(i16),
Bar { x: u8, y: i16 },
Baz,
}
/// cbindgen:prefix-with-name
#[repr(C)]
enum H ... | c3,
c4 = 5,
}
#[repr(u8)] | random_line_split |
day14.rs | extern crate regex;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use regex::Regex;
#[derive(Debug, Clone)]
struct Reindeer {
name: String,
speed: isize,
speed_time: isize,
rest_time: isize,
current_distance: isize,
points: isize,
rest_time_left: isize,
speed_tim... |
fn main() {
let file = File::open("input.txt").unwrap();
let reader = BufReader::new(&file);
let regex = Regex::new(r"(?P<name>[[:alpha:]]+) can fly (?P<speed>[[:digit:]]+) km/s for (?P<speed_time>[[:digit:]]+) seconds, but then must rest for (?P<rest_time>[[:digit:]]+) seconds.").unwrap();
let mut r... | {
let mut reindeers = reindeers;
let time_in_secs = 2503;
for _ in 0..time_in_secs {
for r in reindeers.iter_mut() {
r.tick();
}
// Find the winning reindeer and award them a point.
award_points(&mut reindeers);
}
for r in reindeers.iter() {
print... | identifier_body |
day14.rs | extern crate regex;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use regex::Regex;
#[derive(Debug, Clone)]
struct Reindeer {
name: String,
speed: isize,
speed_time: isize,
rest_time: isize,
current_distance: isize,
points: isize,
rest_time_left: isize,
speed_tim... | else {
self.rest_time_left -= 1;
if self.rest_time_left == 0 {
self.speed_time_left = self.speed_time;
}
}
}
}
fn award_points(reindeers: &mut Vec<Reindeer>) {
let mut max_distance = 0;
for r in reindeers.iter() {
if r.current_distance > ... | {
self.current_distance += self.speed;
self.speed_time_left -= 1;
if self.speed_time_left == 0 {
self.rest_time_left = self.rest_time;
}
} | conditional_block |
day14.rs | extern crate regex;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use regex::Regex;
#[derive(Debug, Clone)]
struct Reindeer {
name: String,
speed: isize,
speed_time: isize,
rest_time: isize,
current_distance: isize,
points: isize,
rest_time_left: isize,
speed_tim... | }
fn part1(reindeers: Vec<Reindeer>) {
let time_in_secs = 2503;
for r in reindeers.iter() {
println!("{:10} traveled {:4} km in {:5} seconds",
r.name,
r.distance_traveled(time_in_secs),
time_in_secs);
}
}
fn part2(reindeers: Vec<Reindeer>) {
l... | random_line_split | |
day14.rs | extern crate regex;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use regex::Regex;
#[derive(Debug, Clone)]
struct Reindeer {
name: String,
speed: isize,
speed_time: isize,
rest_time: isize,
current_distance: isize,
points: isize,
rest_time_left: isize,
speed_tim... | (reindeers: Vec<Reindeer>) {
let mut reindeers = reindeers;
let time_in_secs = 2503;
for _ in 0..time_in_secs {
for r in reindeers.iter_mut() {
r.tick();
}
// Find the winning reindeer and award them a point.
award_points(&mut reindeers);
}
for r in reind... | part2 | identifier_name |
req.rs | use crate::codec::*;
use crate::endpoint::Endpoint;
use crate::error::*;
use crate::transport::AcceptStopHandle;
use crate::util::{Peer, PeerIdentity};
use crate::*;
use crate::{SocketType, ZmqResult};
use async_trait::async_trait;
use bytes::Bytes;
use crossbeam::queue::SegQueue;
use dashmap::DashMap;
use futures::{S... |
pub struct ReqSocket {
backend: Arc<ReqSocketBackend>,
current_request: Option<PeerIdentity>,
binds: HashMap<Endpoint, AcceptStopHandle>,
}
impl Drop for ReqSocket {
fn drop(&mut self) {
self.backend.shutdown();
}
}
#[async_trait]
impl SocketSend for ReqSocket {
async fn send(&mut sel... | pub(crate) peers: DashMap<PeerIdentity, Peer>,
pub(crate) round_robin: SegQueue<PeerIdentity>,
socket_monitor: Mutex<Option<mpsc::Sender<SocketEvent>>>,
socket_options: SocketOptions,
} | random_line_split |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.