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 |
|---|---|---|---|---|
formatter.rs | use ansi_term::Colour::Green;
use ansi_term::Colour::Yellow;
use app::machine::Machine;
fn get_empty_line() -> String {
String::from("")
}
fn get_header() -> String {
let o = format!("{0: ^10} | {1: ^10} | {2: ^10} | {3: ^10}",
"Number",
"Name",
"St... | (machines: &[Machine]) -> String {
let mut lines = Vec::new();
lines.push(get_empty_line());
lines.push(get_header());
lines.push(get_separator());
for machine in machines {
lines.push(get_machine_line(machine));
}
lines.push(get_empty_line());
lines.join("\n")
}
| format | identifier_name |
formatter.rs | use ansi_term::Colour::Green;
use ansi_term::Colour::Yellow;
use app::machine::Machine;
fn get_empty_line() -> String {
String::from("")
}
fn get_header() -> String {
let o = format!("{0: ^10} | {1: ^10} | {2: ^10} | {3: ^10}",
"Number",
"Name",
"St... | machine.get_name(),
machine.get_state(),
machine.get_path());
format!("{}", Green.paint(line))
}
fn get_separator() -> String {
let s = format!("{0: ^10} | {1: ^10} | {2: ^10} | {3: ^10}",
"----------",
... | random_line_split | |
board_naive.rs | use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::str::FromStr;
use std::fmt;
use std::mem;
use piece::Stone;
use piece::Piece;
use piece::Player;
use board::Board;
use board::PieceIter;
use board::PieceCount;
use board::board_from_str;
use board::str_from_board;
use point::Point;
use turn::Dire... | else {
Some(piece.owner())
})
}
// Used for winning the flats
pub fn scorer(&self) -> Option<Player> {
self.pieces.last().and_then(|piece|
if piece.stone() == Stone::Flat {
Some(piece.owner())
} else {
None
... | {
None
} | conditional_block |
board_naive.rs | use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::str::FromStr;
use std::fmt;
use std::mem;
use piece::Stone;
use piece::Piece;
use piece::Player;
use board::Board;
use board::PieceIter;
use board::PieceCount;
use board::board_from_str;
use board::str_from_board;
use point::Point;
use turn::Dire... |
}
| {
str_from_board(self, f)
} | identifier_body |
board_naive.rs | use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::str::FromStr;
use std::fmt;
use std::mem;
use piece::Stone;
use piece::Piece;
use piece::Player;
use board::Board;
use board::PieceIter;
use board::PieceCount;
use board::board_from_str;
use board::str_from_board;
use point::Point;
use turn::Dire... | (&self) -> Option<Player> {
self.pieces.last().and_then(|piece|
if piece.stone() == Stone::Flat {
Some(piece.owner())
} else {
None
})
}
}
#[derive(Clone, Debug, RustcDecodable, RustcEncodable)]
pub struct NaiveBoard {
grid: Vec<Vec<Sq... | scorer | identifier_name |
board_naive.rs | use std::collections::VecDeque;
use std::collections::BTreeSet;
use std::str::FromStr;
use std::fmt;
use std::mem;
use piece::Stone;
use piece::Piece;
use piece::Player;
use board::Board;
use board::PieceIter;
use board::PieceCount;
use board::board_from_str;
use board::str_from_board;
use point::Point;
use turn::Dire... |
// Used for moving stones eligibility
pub fn mover(&self) -> Option<Player> {
self.pieces.last().map(|piece| piece.owner())
}
// Used for road wins
pub fn owner(&self) -> Option<Player> {
self.pieces.last().and_then(|piece|
if piece.stone() == Stone::Standing {
... | self.pieces.push(piece);
Ok(())
} | random_line_split |
lib.rs | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0.
#![feature(const_fn_fn_ptr_basics)]
//! This crate contains some necessary types and traits for implementing a custom coprocessor plugin
//! for TiKV.
//!
//! Most notably, if you want to write a custom plugin, your plugin needs to implement the
//! [`... |
#[doc(hidden)]
pub mod allocator;
mod plugin_api;
mod storage_api;
mod util;
pub use plugin_api::*;
pub use storage_api::*;
pub use util::*; | //! declare_plugin!(MyPlugin::default());
//! ``` | random_line_split |
cleanup-rvalue-temp-during-incomplete-alloc.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 do_it(x: &[uint]) -> Foo {
fail!()
}
fn get_bar(x: uint) -> Vec<uint> { vec!(x * 2) }
pub fn fails() {
let x = 2;
let mut y = Vec::new();
y.push(box Bickwick(do_it(get_bar(x).as_slice())));
}
pub fn main() {
task::try(fails);
} | struct Foo { field: Box<uint> } | random_line_split |
cleanup-rvalue-temp-during-incomplete-alloc.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 ... | (x: uint) -> Vec<uint> { vec!(x * 2) }
pub fn fails() {
let x = 2;
let mut y = Vec::new();
y.push(box Bickwick(do_it(get_bar(x).as_slice())));
}
pub fn main() {
task::try(fails);
}
| get_bar | identifier_name |
cleanup-rvalue-temp-during-incomplete-alloc.rs | // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
pub fn main() {
task::try(fails);
}
| {
let x = 2;
let mut y = Vec::new();
y.push(box Bickwick(do_it(get_bar(x).as_slice())));
} | identifier_body |
coroutine.rs | use ffi::Timeout;
use core::{AsIoContext, IoContext, ThreadIoContext, Cancel};
use handler::{Handler};
use strand::{Strand, StrandImmutable, StrandHandler};
use SteadyTimer;
use context::{Context, Transfer};
use context::stack::{ProtectedFixedSizeStack, Stack, StackError};
trait CoroutineExec: Send +'static {
fn ... | <R, E>(StrandHandler<CoroutineData, Caller<R, E>, R, E>);
impl<R, E> Handler<R, E> for CoroutineHandler<R, E>
where
R: Send +'static,
E: Send +'static,
{
type Output = Result<R, E>;
#[doc(hidden)]
type WrappedHandler = StrandHandler<CoroutineData, fn(Strand<CoroutineData>, Result<R, E>), R, E>;
... | CoroutineHandler | identifier_name |
coroutine.rs | use ffi::Timeout;
use core::{AsIoContext, IoContext, ThreadIoContext, Cancel};
use handler::{Handler};
use strand::{Strand, StrandImmutable, StrandHandler};
use SteadyTimer;
use context::{Context, Transfer};
use context::stack::{ProtectedFixedSizeStack, Stack, StackError};
trait CoroutineExec: Send +'static {
fn ... | ),
)
}
}
unsafe impl Send for CancelRef {}
unsafe impl Sync for CancelRef {}
type Caller<R, E> = fn(Strand<CoroutineData>, Result<R, E>);
pub struct CoroutineHandler<R, E>(StrandHandler<CoroutineData, Caller<R, E>, R, E>);
impl<R, E> Handler<R, E> for CoroutineHandler<R, E>
where
R: Send +'static,
... | {
unsafe { &*self.0 }.cancel();
} | conditional_block |
coroutine.rs | use ffi::Timeout;
use core::{AsIoContext, IoContext, ThreadIoContext, Cancel};
use handler::{Handler};
use strand::{Strand, StrandImmutable, StrandHandler};
use SteadyTimer;
use context::{Context, Transfer};
use context::stack::{ProtectedFixedSizeStack, Stack, StackError};
trait CoroutineExec: Send +'static {
fn ... |
}
unsafe impl Send for CancelRef {}
unsafe impl Sync for CancelRef {}
type Caller<R, E> = fn(Strand<CoroutineData>, Result<R, E>);
pub struct CoroutineHandler<R, E>(StrandHandler<CoroutineData, Caller<R, E>, R, E>);
impl<R, E> Handler<R, E> for CoroutineHandler<R, E>
where
R: Send +'static,
E: Send +'stat... | {
coro.timer.expires_from_now(unsafe { &*self.1 }.get());
coro.timer.async_wait(
coro.wrap(move |_, res| if let Ok(_) = res {
unsafe { &*self.0 }.cancel();
}),
)
} | identifier_body |
coroutine.rs | use ffi::Timeout;
use core::{AsIoContext, IoContext, ThreadIoContext, Cancel};
use handler::{Handler};
use strand::{Strand, StrandImmutable, StrandHandler};
use SteadyTimer;
use context::{Context, Transfer};
use context::stack::{ProtectedFixedSizeStack, Stack, StackError};
trait CoroutineExec: Send +'static {
fn ... | .take()
.unwrap();
let mut coro: StrandImmutable<CoroutineData> = Strand::new(
&ctx,
CoroutineData {
context: Some(t.context),
timer: SteadyTimer::new(&ctx),
},
);
let this = {
let data = &coro ... | let InitData { stack, ctx, exec } = unsafe { &mut *(t.data as *mut Option<InitData>) } | random_line_split |
fs.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 ... | (&self) -> u64 { self.as_inner().created() }
fn last_access_time(&self) -> u64 { self.as_inner().accessed() }
fn last_write_time(&self) -> u64 { self.as_inner().modified() }
fn file_size(&self) -> u64 { self.as_inner().size() }
}
/// Creates a new file symbolic link on the filesystem.
///
/// The `dst` pat... | creation_time | identifier_name |
fs.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 ... |
}
/// Creates a new file symbolic link on the filesystem.
///
/// The `dst` path will be a file symbolic link pointing to the `src`
/// path.
///
/// # Examples
///
/// ```ignore
/// use std::os::windows::fs;
///
/// # fn foo() -> std::io::Result<()> {
/// try!(fs::symlink_file("a.txt", "b.txt"));
/// # Ok(())
/// # ... | { self.as_inner().size() } | identifier_body |
fs.rs | // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | use prelude::v1::*;
use fs::{OpenOptions, Metadata};
use io;
use path::Path;
use sys;
use sys_common::{AsInnerMut, AsInner};
/// Windows-specific extensions to `OpenOptions`
#[unstable(feature = "fs_ext", reason = "may require more thought/methods")]
pub trait OpenOptionsExt {
/// Overrides the `dwDesiredAccess` ... | random_line_split | |
lib.rs | //! Vector dot product
#![deny(warnings, rust_2018_idioms)]
#![feature(custom_inner_attributes)]
pub mod scalar;
pub mod simd;
#[cfg(test)]
#[rustfmt::skip] | (&[1_f32, 2., 3., 4.], &[1_f32, 2., 3., 4.], 30_f32),
(&[1_f32, 2., 3., 4., 1., 2., 3., 4.], &[1_f32, 1., 1., 1., 1., 1., 1., 1.], 20_f32),
];
for &(a, b, output) in tests {
assert_eq!(f(a, b), output);
}
} | fn test<F: Fn(&[f32], &[f32]) -> f32>(f: F) {
let tests: &[(&[f32], &[f32], f32)] = &[
(&[0_f32, 0., 0., 0.], &[0_f32, 0., 0., 0.], 0_f32),
(&[0_f32, 0., 0., 1.], &[0_f32, 0., 0., 1.], 1_f32),
(&[1_f32, 2., 3., 4.], &[0_f32, 0., 0., 0.], 0_f32), | random_line_split |
lib.rs | //! Vector dot product
#![deny(warnings, rust_2018_idioms)]
#![feature(custom_inner_attributes)]
pub mod scalar;
pub mod simd;
#[cfg(test)]
#[rustfmt::skip]
fn | <F: Fn(&[f32], &[f32]) -> f32>(f: F) {
let tests: &[(&[f32], &[f32], f32)] = &[
(&[0_f32, 0., 0., 0.], &[0_f32, 0., 0., 0.], 0_f32),
(&[0_f32, 0., 0., 1.], &[0_f32, 0., 0., 1.], 1_f32),
(&[1_f32, 2., 3., 4.], &[0_f32, 0., 0., 0.], 0_f32),
(&[1_f32, 2., 3., 4.], &[1_f32, 2., 3., 4.], ... | test | identifier_name |
lib.rs | //! Vector dot product
#![deny(warnings, rust_2018_idioms)]
#![feature(custom_inner_attributes)]
pub mod scalar;
pub mod simd;
#[cfg(test)]
#[rustfmt::skip]
fn test<F: Fn(&[f32], &[f32]) -> f32>(f: F) | {
let tests: &[(&[f32], &[f32], f32)] = &[
(&[0_f32, 0., 0., 0.], &[0_f32, 0., 0., 0.], 0_f32),
(&[0_f32, 0., 0., 1.], &[0_f32, 0., 0., 1.], 1_f32),
(&[1_f32, 2., 3., 4.], &[0_f32, 0., 0., 0.], 0_f32),
(&[1_f32, 2., 3., 4.], &[1_f32, 2., 3., 4.], 30_f32),
(&[1_f32, 2., 3., 4.... | identifier_body | |
keyframes.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/. */
//! Keyframes: https://drafts.csswg.org/css-animations/#keyframes
#![deny(missing_docs)]
use cssparser::{AtRuleP... | (&self, other: &Self) -> ::std::cmp::Ordering {
// We know we have a number from 0 to 1, so unwrap() here is safe.
self.0.partial_cmp(&other.0).unwrap()
}
}
impl ::std::cmp::Eq for KeyframePercentage { }
impl ToCss for KeyframePercentage {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where... | cmp | identifier_name |
keyframes.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/. */
//! Keyframes: https://drafts.csswg.org/css-animations/#keyframes
#![deny(missing_docs)]
use cssparser::{AtRuleP... |
/// Deep clones this Keyframe.
pub fn deep_clone_with_lock(&self,
lock: &SharedRwLock) -> Keyframe {
let guard = lock.read();
Keyframe {
selector: self.selector.clone(),
block: Arc::new(lock.wrap(self.block.read_with(&guard).clone())),
... | {
let error_reporter = NullReporter;
let context = ParserContext::new(parent_stylesheet.origin,
&parent_stylesheet.url_data,
&error_reporter,
Some(CssRuleType::Keyframe),
... | identifier_body |
keyframes.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/. */
//! Keyframes: https://drafts.csswg.org/css-animations/#keyframes
#![deny(missing_docs)]
use cssparser::{AtRuleP... | }
}
/// Return specified TransitionTimingFunction if this KeyframesSteps has 'animation-timing-function'.
pub fn get_animation_timing_function(&self, guard: &SharedRwLockReadGuard)
-> Option<SpecifiedTimingFunction> {
if!self.declared_timing_function... | start_percentage: percentage,
value: value,
declared_timing_function: declared_timing_function, | random_line_split |
clipboard_linux.rs | use std::process::{Stdio, Command};
use std::io::Write; | Ok(status) => if!status.success() { return Err("missing xclip program".to_string()) },
Err(e) => return Err(e.detail().unwrap_or("unknown IO error".to_string()))
}
let output = match Command::new("xclip").args(&["-out", "-selection", "clipboard"]).output() {
Ok(output) => output,
... |
pub fn read() -> Result<String, String> {
match Command::new("which").arg("xclip").status() { | random_line_split |
clipboard_linux.rs | use std::process::{Stdio, Command};
use std::io::Write;
pub fn read() -> Result<String, String> {
match Command::new("which").arg("xclip").status() {
Ok(status) => if!status.success() { return Err("missing xclip program".to_string()) },
Err(e) => return Err(e.detail().unwrap_or("unknown IO error".t... | }
| {
match Command::new("which").arg("xclip").status() {
Ok(status) => if !status.success() { return Err("missing xclip program".to_string()) },
Err(e) => return Err(e.detail().unwrap_or("unknown IO error".to_string()))
}
let mut child = match Command::new("xclip").args(&["-in", "-selection", ... | identifier_body |
clipboard_linux.rs | use std::process::{Stdio, Command};
use std::io::Write;
pub fn | () -> Result<String, String> {
match Command::new("which").arg("xclip").status() {
Ok(status) => if!status.success() { return Err("missing xclip program".to_string()) },
Err(e) => return Err(e.detail().unwrap_or("unknown IO error".to_string()))
}
let output = match Command::new("xclip").arg... | read | identifier_name |
restrictions.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,
cmt: mc::cmt,
restrictions: RestrictionSet) -> RestrictionResult {
// Check for those cases where we cannot control the aliasing
// and make sure that we are not being asked to.
match cmt.freely_aliasable() {
None => {}
Some(cause)... | restrict | identifier_name |
restrictions.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 ... |
mc::cat_deref(cmt_base, _, pk @ mc::region_ptr(MutMutable, lt)) => {
// R-Deref-Mut-Borrowed
if!self.bccx.is_subregion_of(self.loan_region, lt) {
self.bccx.report(
BckError {
span: self.span,
... | {
// R-Deref-Imm-Managed
Safe
} | conditional_block |
restrictions.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 ... | cmt: cmt_base,
code: err_borrowed_pointer_too_short(
self.loan_region, lt, restrictions)});
return Safe;
}
let result = self.restrict(cmt_base, restrictions);
self... | if !self.bccx.is_subregion_of(self.loan_region, lt) {
self.bccx.report(
BckError {
span: self.span, | random_line_split |
config.rs | pub use errors::*;
use serde::Deserialize;
use std::{error, fmt};
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use toml;
const DEFAULT_GIT_CACHE_DIRECTORY: &'static str = "cache";
#[derive(Debug, Clone)]
pub struct Config {
pub gitlab: Gitlab,
pub ... | {
gitlab: RawGitlab,
git: RawGit,
repo: HashMap<String, RawRepo>,
}
impl Into<Config> for RawConfig {
fn into(self) -> Config {
Config {
gitlab: self.gitlab.into(),
git: self.git.into(),
repo: self.repo.into_iter().map(|(name, repo)| (name, repo.into())).col... | RawConfig | identifier_name |
config.rs | pub use errors::*;
use serde::Deserialize;
use std::{error, fmt};
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use toml;
const DEFAULT_GIT_CACHE_DIRECTORY: &'static str = "cache";
#[derive(Debug, Clone)]
pub struct Config {
pub gitlab: Gitlab,
pub ... |
fn cause(&self) -> Option<&error::Error> {
self.raw.cause()
}
}
| {
self.raw.description()
} | identifier_body |
config.rs | pub use errors::*;
use serde::Deserialize;
use std::{error, fmt};
use std::collections::HashMap;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use toml;
const DEFAULT_GIT_CACHE_DIRECTORY: &'static str = "cache";
#[derive(Debug, Clone)]
pub struct Config {
pub gitlab: Gitlab,
pub ... | pub struct TomlParserError {
lo_pos: (usize, usize),
hi_pos: (usize, usize),
raw: toml::ParserError,
}
impl TomlParserError {
fn new(parser: &toml::Parser) -> Option<TomlParserError> {
if parser.errors.is_empty() {
return None;
}
let e = &parser.errors[0];
So... | random_line_split | |
metadata.rs | /*
* Copyright 2021 Google LLC
*
* 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 agreed to i... |
}
impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Bool(a), Self::Bool(b)) => a == b,
(Self::Bool(_), _) => false,
(Self::Number(a), Self::Number(b)) => a == b,
(Self::Number(_), _) => false,
(Self::Lis... | {
Self::Bytes(bytes::Bytes::copy_from_slice(value))
} | identifier_body |
metadata.rs | /*
* Copyright 2021 Google LLC
*
* 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 agreed to i... | }
impl PartialEq for Value {
fn eq(&self, other: &Self) -> bool {
match (self, other) {
(Self::Bool(a), Self::Bool(b)) => a == b,
(Self::Bool(_), _) => false,
(Self::Number(a), Self::Number(b)) => a == b,
(Self::Number(_), _) => false,
(Self::List... | random_line_split | |
metadata.rs | /*
* Copyright 2021 Google LLC
*
* 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 agreed to i... | (mut value: ProtoMetadata) -> Result<Self, Self::Error> {
let known = value
.filter_metadata
.remove(KEY)
.map(T::try_from)
.transpose()?
.unwrap_or_default();
let value = prost_types::value::Kind::StructValue(prost_types::Struct {
fiel... | try_from | identifier_name |
inline.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 ... |
_ => {}
}
local_def(item.id)
}
csearch::found(ast::IIForeign(item)) => {
ccx.external.borrow_mut().insert(fn_id, Some(item.id));
ccx.external_srcs.borrow_mut().insert(item.id, fn_id);
local_def(item.id)
}
csear... | {
let g = get_item_val(ccx, item.id);
// see the comment in get_item_val() as to why this check is
// performed here.
if ast_util::static_has_significant_address(
mutbl,
item.attrs.as_... | conditional_block |
inline.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,b,c,d| astencode::decode_inlined_item(a, b, c, d));
return match csearch_result {
csearch::not_found => {
ccx.external.borrow_mut().insert(fn_id, None);
fn_id
}
csearch::found(ast::IIItem(item)) => {
ccx.external.borrow_mut().insert(fn_id, S... | {
let _icx = push_ctxt("maybe_instantiate_inline");
match ccx.external.borrow().find(&fn_id) {
Some(&Some(node_id)) => {
// Already inline
debug!("maybe_instantiate_inline({}): already inline as node id {}",
ty::item_path_str(ccx.tcx(), fn_id), node_id);
... | identifier_body |
inline.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 ... | (ccx: &CrateContext, fn_id: ast::DefId)
-> ast::DefId {
let _icx = push_ctxt("maybe_instantiate_inline");
match ccx.external.borrow().find(&fn_id) {
Some(&Some(node_id)) => {
// Already inline
debug!("maybe_instantiate_inline({}): already inline as node id {}",
... | maybe_instantiate_inline | identifier_name |
inline.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 ... | }
_ => {}
}
local_def(item.id)
}
csearch::found(ast::IIForeign(item)) => {
ccx.external.borrow_mut().insert(fn_id, Some(item.id));
ccx.external_srcs.borrow_mut().insert(item.id, fn_id);
local_def(item.id)
... | mutbl,
item.attrs.as_slice()) {
SetLinkage(g, AvailableExternallyLinkage);
} | random_line_split |
main.rs |
#![feature(convert)]
extern crate revord;
use revord::RevOrd;
use std::str::from_utf8;
use std::collections::{HashSet, BinaryHeap};
fn calibrate(challenge: &str, productions: &Vec<(&str, &str)>) -> usize |
// There is pretty much going on for part two. I should clean this mess up.
fn reduce(challenge: &String, productions: &Vec<(&str, &str)>, steps: usize)
-> (String, usize) {
let mut queue = BinaryHeap::new();
let mut seen = HashSet::new();
let mut latest = (challenge.clone(), steps);
queue.pus... | {
let mut words = HashSet::new();
for &(symbol, replacement) in productions {
for (index, _) in challenge.match_indices(symbol) {
let (head, tail) = challenge.split_at(index);
let result = format!("{}{}{}", head, replacement,
&tail[symbol.len()..... | identifier_body |
main.rs | #![feature(convert)]
extern crate revord;
use revord::RevOrd;
use std::str::from_utf8;
use std::collections::{HashSet, BinaryHeap};
fn calibrate(challenge: &str, productions: &Vec<(&str, &str)>) -> usize {
let mut words = HashSet::new();
for &(symbol, replacement) in productions {
for (index, _) in c... | if tokens.len() < 3 || tokens[0].len() > tokens[2].len() {
// We do not allow productions that reduce the input length.
panic!(PARSE_ERROR);
}
productions.push((tokens[0], tokens[2]));
}
let solution = calibrate(challenge, &productions);
println!("{} molecul... | random_line_split | |
main.rs |
#![feature(convert)]
extern crate revord;
use revord::RevOrd;
use std::str::from_utf8;
use std::collections::{HashSet, BinaryHeap};
fn calibrate(challenge: &str, productions: &Vec<(&str, &str)>) -> usize {
let mut words = HashSet::new();
for &(symbol, replacement) in productions {
for (index, _) in ... | (medicine: &str, productions: &Vec<(&str, &str)>)
-> Option<usize> {
let mut productions = productions.clone();
productions.sort_by(|&(_, a), &(_, b)| b.len().cmp(&a.len()));
let mut challenge = medicine.to_string();
let mut steps = 0;
while challenge!= "e" {
let (new_challenge, total... | fabricate | identifier_name |
builder.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::Duration;
use anyhow::{Context, Error};
use url::Url;
use any... | (mut self, size: Option<usize>) -> Self {
self.max_trees = size;
self
}
/// Maximum number of keys per history request. Larger requests will be
/// split up into concurrently-sent batches.
pub fn max_history(mut self, size: Option<usize>) -> Self {
self.max_history = size;
... | max_trees | identifier_name |
builder.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::Duration;
use anyhow::{Context, Error};
use url::Url;
use any... |
// Setting these to 0 is the same as None.
let max_files = max_files.filter(|n| *n > 0);
let max_trees = max_trees.filter(|n| *n > 0);
let max_history = max_history.filter(|n| *n > 0);
Ok(Config {
server_url,
cert,
key,
ca_bundle... | {
let path = format!("{}/", server_url.path());
server_url.set_path(&path);
} | conditional_block |
builder.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::Duration;
use anyhow::{Context, Error};
use url::Url;
use any... | self
}
/// Specify the client's private key
pub fn key(mut self, key: impl AsRef<Path>) -> Self {
self.key = Some(key.as_ref().into());
self
}
/// Specify a CA certificate bundle to be used to validate the server's
/// TLS certificate in place of the default system cert... | /// The corresponding private key may either be provided in the same file
/// as the certificate, or separately using the `key` method.
pub fn cert(mut self, cert: impl AsRef<Path>) -> Self {
self.cert = Some(cert.as_ref().into()); | random_line_split |
builder.rs | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use std::collections::HashMap;
use std::path::{Path, PathBuf};
use std::time::Duration;
use anyhow::{Context, Error};
use url::Url;
use any... |
/// Maximum number of keys per history request. Larger requests will be
/// split up into concurrently-sent batches.
pub fn max_history(mut self, size: Option<usize>) -> Self {
self.max_history = size;
self
}
/// Maximum number of locations per location to has request. Larger req... | {
self.max_trees = size;
self
} | identifier_body |
documentfragment.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding;... |
// https://dom.spec.whatwg.org/#dom-parentnode-append
fn Append(&self, nodes: Vec<NodeOrString>) -> ErrorResult {
self.upcast::<Node>().append(nodes)
}
// https://dom.spec.whatwg.org/#dom-parentnode-queryselector
fn QuerySelector(&self, selectors: DOMString) -> Fallible<Option<DomRoot<Ele... | {
self.upcast::<Node>().prepend(nodes)
} | identifier_body |
documentfragment.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding;... | }
} | random_line_split | |
documentfragment.rs | /* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use crate::dom::bindings::cell::DomRefCell;
use crate::dom::bindings::codegen::Bindings::DocumentFragmentBinding;... | (&self, selectors: DOMString) -> Fallible<DomRoot<NodeList>> {
self.upcast::<Node>().query_selector_all(selectors)
}
}
| QuerySelectorAll | identifier_name |
maybe_owned_vec.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 ... |
}
impl<'a, T: Clone> Clone for MaybeOwnedVector<'a, T> {
fn clone(&self) -> MaybeOwnedVector<'a, T> {
match *self {
Growable(ref v) => Growable(v.to_vec()),
Borrowed(v) => Borrowed(v)
}
}
}
impl<'a, T> Default for MaybeOwnedVector<'a, T> {
fn default() -> MaybeOwn... | {
match self {
Growable(v) => v.as_slice().to_vec(),
Borrowed(v) => v.to_vec(),
}
} | identifier_body |
maybe_owned_vec.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 ... | }
}
impl<'a, T> Default for MaybeOwnedVector<'a, T> {
fn default() -> MaybeOwnedVector<'a, T> {
Growable(Vec::new())
}
}
impl<'a, T> Collection for MaybeOwnedVector<'a, T> {
fn len(&self) -> uint {
self.as_slice().len()
}
}
impl<'a> BytesContainer for MaybeOwnedVector<'a, u8> {
... | fn clone(&self) -> MaybeOwnedVector<'a, T> {
match *self {
Growable(ref v) => Growable(v.to_vec()),
Borrowed(v) => Borrowed(v)
} | random_line_split |
maybe_owned_vec.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 ... | <I:Iterator<T>>(iterator: I) -> MaybeOwnedVector<'a,T> {
// If we are building from scratch, might as well build the
// most flexible variant.
Growable(FromIterator::from_iter(iterator))
}
}
impl<'a,T:fmt::Show> fmt::Show for MaybeOwnedVector<'a,T> {
fn fmt(&self, f: &mut fmt::Formatter... | from_iter | identifier_name |
lib.rs | use std::collections::HashMap;
use std::path::Path;
use std::fs::File;
use std::error::Error;
use std::io::BufReader;
use std::io::prelude::*;
pub mod actor;
mod log_entry;
mod http;
mod hash_utils;
mod nginx;
pub fn | (logfile: &str) -> Result<HashMap<String, actor::Actor>, String> {
let path = Path::new(logfile);
let file_handle = match File::open(&path) {
Err(why) => {
return Err(format!("Could not open {} : {}", path.display(), Error::description(&why)));
},
Ok(file) => file,
};
... | process | identifier_name |
lib.rs | use std::collections::HashMap;
use std::path::Path;
use std::fs::File;
use std::error::Error;
use std::io::BufReader;
use std::io::prelude::*; | mod hash_utils;
mod nginx;
pub fn process(logfile: &str) -> Result<HashMap<String, actor::Actor>, String> {
let path = Path::new(logfile);
let file_handle = match File::open(&path) {
Err(why) => {
return Err(format!("Could not open {} : {}", path.display(), Error::description(&why)));
... |
pub mod actor;
mod log_entry;
mod http; | random_line_split |
lib.rs | use std::collections::HashMap;
use std::path::Path;
use std::fs::File;
use std::error::Error;
use std::io::BufReader;
use std::io::prelude::*;
pub mod actor;
mod log_entry;
mod http;
mod hash_utils;
mod nginx;
pub fn process(logfile: &str) -> Result<HashMap<String, actor::Actor>, String> | {
let path = Path::new(logfile);
let file_handle = match File::open(&path) {
Err(why) => {
return Err(format!("Could not open {} : {}", path.display(), Error::description(&why)));
},
Ok(file) => file,
};
let reader = BufReader::new(file_handle);
let mut actors = ... | identifier_body | |
recent_chooser_dialog.rs | // Copyright 2013-2015, 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 std::ptr;
use glib::translate::ToGlibPtr;
use ffi;
use FFIWidget;
use DialogButtons;
use ... |
pub fn new_for_manager<T: DialogButtons>(title: &str, parent: Option<&::Window>,
manager: &::RecentManager, buttons: T) -> RecentChooserDialog {
let parent = match parent {
Some(ref p) => GTK_WINDOW(p.unwrap_widget()),
None => ptr::null_... | {
let parent = match parent {
Some(ref p) => GTK_WINDOW(p.unwrap_widget()),
None => ptr::null_mut()
};
unsafe {
::FFIWidget::wrap_widget(
buttons.invoke2(
ffi::gtk_recent_chooser_dialog_new,
title.to_gli... | identifier_body |
recent_chooser_dialog.rs | // Copyright 2013-2015, 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 std::ptr;
use glib::translate::ToGlibPtr;
use ffi;
use FFIWidget;
use DialogButtons;
use ... | <T: DialogButtons>(title: &str, parent: Option<&::Window>,
buttons: T) -> RecentChooserDialog {
let parent = match parent {
Some(ref p) => GTK_WINDOW(p.unwrap_widget()),
None => ptr::null_mut()
};
unsafe {
::FFIWidget::wrap_wi... | new | identifier_name |
recent_chooser_dialog.rs | // Copyright 2013-2015, 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 std::ptr;
use glib::translate::ToGlibPtr;
use ffi;
use FFIWidget; | struct_Widget!(RecentChooserDialog);
impl RecentChooserDialog {
pub fn new<T: DialogButtons>(title: &str, parent: Option<&::Window>,
buttons: T) -> RecentChooserDialog {
let parent = match parent {
Some(ref p) => GTK_WINDOW(p.unwrap_widget()),
None =... | use DialogButtons;
use cast::{GTK_WINDOW, GTK_RECENT_MANAGER};
| random_line_split |
fs.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... |
}
impl DirBuilder {
pub fn new() -> DirBuilder {
DirBuilder { mode: 0o777 }
}
pub fn mkdir(&self, p: &Path) -> io::Result<()> {
let p = try!(cstr(p));
try!(cvt(unsafe { libc::mkdir(p.as_ptr(), self.mode) }));
Ok(())
}
pub fn set_mode(&mut self, mode: mode_t) {
... | { &self.0 } | identifier_body |
fs.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | (&self) -> &[u8] {
extern {
fn rust_list_dir_val(ptr: *mut libc::dirent_t) -> *const c_char;
}
unsafe {
CStr::from_ptr(rust_list_dir_val(self.dirent())).to_bytes()
}
}
fn dirent(&self) -> *mut libc::dirent_t {
self.buf.as_ptr() as *mut _
}
}
... | name_bytes | identifier_name |
fs.rs | // Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MI... | use io::prelude::*;
use os::unix::prelude::*;
use ffi::{CString, CStr, OsString, OsStr};
use fmt;
use io::{self, Error, SeekFrom};
use libc::{self, c_int, size_t, off_t, c_char, mode_t};
use mem;
use path::{Path, PathBuf};
use ptr;
use sync::Arc;
use sys::fd::FileDesc;
use sys::platform::raw;
use sys::{c, cvt, cvt_r};... | // except according to those terms.
use core::prelude::*; | random_line_split |
issue-50825-1.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | trait Y<U>: X {
fn foo(x: &Self::T);
}
impl X for () {
type T = ();
}
impl<T> Y<Vec<T>> for () where (): Y<T> {
fn foo(_x: &()) {}
}
fn main () {} |
trait X {
type T;
}
| random_line_split |
issue-50825-1.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... |
}
fn main () {}
| {} | identifier_body |
issue-50825-1.rs | // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or ... | () {}
| main | identifier_name |
print_operation_preview.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 PrintContext;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::transla... | <P>(this: *mut ffi::GtkPrintOperationPreview, context: *mut ffi::GtkPrintContext, f: glib_ffi::gpointer)
where P: IsA<PrintOperationPreview> {
let f: &&(Fn(&P, &PrintContext) +'static) = transmute(f);
f(&PrintOperationPreview::from_glib_borrow(this).downcast_unchecked(), &from_glib_borrow(context))
}
| ready_trampoline | identifier_name |
print_operation_preview.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 PrintContext;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::transla... |
fn is_selected(&self, page_nr: i32) -> bool;
fn render_page(&self, page_nr: i32);
fn connect_got_page_size<F: Fn(&Self, &PrintContext, &PageSetup) +'static>(&self, f: F) -> SignalHandlerId;
fn connect_ready<F: Fn(&Self, &PrintContext) +'static>(&self, f: F) -> SignalHandlerId;
}
impl<O: IsA<PrintOp... | fn end_preview(&self); | random_line_split |
print_operation_preview.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 PrintContext;
use ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect;
use glib::transla... |
}
unsafe extern "C" fn got_page_size_trampoline<P>(this: *mut ffi::GtkPrintOperationPreview, context: *mut ffi::GtkPrintContext, page_setup: *mut ffi::GtkPageSetup, f: glib_ffi::gpointer)
where P: IsA<PrintOperationPreview> {
let f: &&(Fn(&P, &PrintContext, &PageSetup) +'static) = transmute(f);
f(&PrintOperat... | {
unsafe {
let f: Box_<Box_<Fn(&Self, &PrintContext) + 'static>> = Box_::new(Box_::new(f));
connect(self.to_glib_none().0, "ready",
transmute(ready_trampoline::<Self> as usize), Box_::into_raw(f) as *mut _)
}
} | identifier_body |
lib.rs | #![allow(clippy::too_many_arguments)]
#![allow(clippy::cognitive_complexity)]
mod config;
mod editor;
mod exit_dialogue;
mod input_area;
mod key_map;
mod line_split;
mod messaging;
#[doc(hidden)]
pub mod msg_area; // Public to be able to use in an example
mod notifier;
mod tab;
mod termbox;
pub mod test_utils;
#[doc(h... | <S>(width: u16, height: u16, input_stream: S) -> (TUI, mpsc::Receiver<Event>)
where
S: Stream<Item = std::io::Result<term_input::Event>> + Unpin +'static,
{
let tui = Rc::new(RefCell::new(tui::TUI::new_test(width, height)));
let inner = Rc::downgrade(&tui);
let (snd_ev, rcv_ev) ... | run_test | identifier_name |
lib.rs | #![allow(clippy::too_many_arguments)]
#![allow(clippy::cognitive_complexity)]
mod config;
mod editor;
mod exit_dialogue;
mod input_area;
mod key_map;
mod line_split;
mod messaging;
#[doc(hidden)]
pub mod msg_area; // Public to be able to use in an example
mod notifier;
mod tab;
mod termbox;
pub mod test_utils;
#[doc(h... | }
} | self.inner
.upgrade()
.map(|tui| tui.borrow().current_tab().clone()) | random_line_split |
defaults.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... | ;
}
}
mod gl {
extern crate libc;
#[cfg(target_os = "macos")]
#[link(name="OpenGL", kind="framework")]
extern { }
#[cfg(target_os = "linux")]
#[link(name="GL")]
extern { }
pub type GLenum = libc::c_uint;
pub type GLint = libc::c_int;
pub static RED_BITS : G... | {
let value = 0;
unsafe { gl::GetIntegerv(param, &value) };
println!("OpenGL {:s}: {}", name, value);
} | conditional_block |
defaults.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... |
extern "C" {
fn glGetIntegerv(pname: GLenum, params: *GLint);
}
}
| {
glGetIntegerv(pname, params)
} | identifier_body |
defaults.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... | ];
for &(param, ext, name) in gl_params.iter() {
if ext.map_or(true, |s| {
glfw.extension_supported(s)
}) {
let value = 0;
unsafe { gl::GetIntegerv(param, &value) };
println!("OpenGL {:s}: {}", name, value);
};
}
}
mod gl {
extern... | (gl::ACCUM_BLUE_BITS, None, "accum blue bits" ),
(gl::ACCUM_ALPHA_BITS, None, "accum alpha bits" ),
(gl::STEREO, None, "stereo" ),
(gl::SAMPLES_ARB, Some("GL_ARB_multisample"), "FSAA samples" ), | random_line_split |
defaults.rs | // Copyright 2013 The GLFW-RS Developers. For a full listing of the authors,
// refer to the AUTHORS file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of... | () {
let glfw = glfw::init(glfw::FAIL_ON_ERRORS).unwrap();
glfw.window_hint(glfw::Visible(true));
let (window, _) = glfw.create_window(640, 480, "Defaults", glfw::Windowed)
.expect("Failed to create GLFW window.");
window.make_current();
let (width, height) = window.get_size();
printl... | main | identifier_name |
target.rs | // Copyright 2014 The Gfx-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 ag... | /// A single depth value from a depth buffer.
pub type Depth = f32;
/// A single value from a stencil stencstencil buffer.
pub type Stencil = u8;
/// A screen space rectangle
#[allow(missing_docs)]
#[derive(Clone, Copy, Debug, Hash, PartialEq, PartialOrd)]
#[cfg_attr(feature="serialize", derive(Serialize, Deserialize)... | random_line_split | |
target.rs | // Copyright 2014 The Gfx-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 ag... | {
pub x: u16,
pub y: u16,
pub w: u16,
pub h: u16,
}
/// A color with floating-point components.
pub type ColorValue = [f32; 4];
bitflags!(
/// Mirroring flags, used for blitting
#[cfg_attr(feature="serialize", derive(Serialize, Deserialize))]
pub flags Mirror: u8 {
#[allow(missing... | Rect | identifier_name |
question.rs | use std::str;
pub struct Question {
pub name: Vec<String>,
pub rrtype: u16,
pub class: u16,
}
impl Question {
pub fn unpack(buffer: &[u8], offset: usize) -> (Question, usize) {
let mut name = Vec::new();
let mut offset = offset;
loop {
let size: usize = buffer[offs... |
name.push(
str::from_utf8(&buffer[offset..offset + size])
.unwrap()
.to_string(),
);
offset += size;
}
let rrtype: u16 = u16::from(buffer[offset]) << 8 | u16::from(buffer[offset + 1]);
offset += 2;
... | {
break;
} | conditional_block |
question.rs | use std::str;
pub struct Question {
pub name: Vec<String>,
pub rrtype: u16,
pub class: u16,
}
impl Question {
pub fn unpack(buffer: &[u8], offset: usize) -> (Question, usize) {
let mut name = Vec::new();
let mut offset = offset;
loop {
let size: usize = buffer[offs... | buffer[offset] = *byte;
offset += 1;
}
}
buffer[offset] = 0 as u8;
offset += 1;
buffer[offset] = (self.rrtype >> 8) as u8;
buffer[offset + 1] = self.rrtype as u8;
offset += 2;
buffer[offset] = (self.class >> 8) as u8;... | buffer[offset] = part.len() as u8;
offset += 1;
for byte in part.to_owned().into_bytes().iter() { | random_line_split |
question.rs | use std::str;
pub struct Question {
pub name: Vec<String>,
pub rrtype: u16,
pub class: u16,
}
impl Question {
pub fn unpack(buffer: &[u8], offset: usize) -> (Question, usize) {
let mut name = Vec::new();
let mut offset = offset;
loop {
let size: usize = buffer[offs... | (&self, buffer: &mut [u8], offset: usize) -> usize {
let mut offset: usize = offset;
for part in self.name.iter() {
buffer[offset] = part.len() as u8;
offset += 1;
for byte in part.to_owned().into_bytes().iter() {
buffer[offset] = *byte;
... | pack | identifier_name |
from_geo.rs | extern crate geos;
extern crate geo_types;
extern crate failure;
use failure::Error;
fn fun() -> Result<(), Error> {
use geos::GGeom;
use geo_types::{LineString, Polygon, Coordinate};
use geos::from_geo::TryInto;
let exterior = LineString(vec![
Coordinate::from((0., 0.)),
Coordinate::from((0., 1.))... | assert_eq!(p.exterior(), &exterior);
assert_eq!(p.interiors(), interiors.as_slice());
let geom: GGeom = (&p).try_into()?;
assert!(geom.contains(&geom)?);
assert!(!geom.contains(&(&exterior).try_into()?)?);
assert!(geom.covers(&(&exterior).try_into()?)?);
assert!(geom.touches(&(&exterior).... | Coordinate::from((0.1, 0.1)),
]),
];
let p = Polygon::new(exterior.clone(), interiors.clone());
| random_line_split |
from_geo.rs | extern crate geos;
extern crate geo_types;
extern crate failure;
use failure::Error;
fn fun() -> Result<(), Error> {
use geos::GGeom;
use geo_types::{LineString, Polygon, Coordinate};
use geos::from_geo::TryInto;
let exterior = LineString(vec![
Coordinate::from((0., 0.)),
Coordinate::from((0., 1.))... | () {
fun().unwrap();
}
| main | identifier_name |
from_geo.rs | extern crate geos;
extern crate geo_types;
extern crate failure;
use failure::Error;
fn fun() -> Result<(), Error> {
use geos::GGeom;
use geo_types::{LineString, Polygon, Coordinate};
use geos::from_geo::TryInto;
let exterior = LineString(vec![
Coordinate::from((0., 0.)),
Coordinate::from((0., 1.))... | {
fun().unwrap();
} | identifier_body | |
problem_04.rs | // Copyright 2014 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 4
// Largest palindrome product
fn is_palindrome(n: int) -> bool {
let size = (n as f64).log10().ceil() as int;
let mut num = n;
let mut digits = Vec::with_capacity((size/2) as uint);
let mut i = 0;
// Push the first half of ... |
}
}
largest
}
| {
largest = c;
} | conditional_block |
problem_04.rs | // Copyright 2014 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 4
// Largest palindrome product
fn is_palindrome(n: int) -> bool {
let size = (n as f64).log10().ceil() as int;
let mut num = n;
let mut digits = Vec::with_capacity((size/2) as uint);
let mut i = 0;
// Push the first half of ... | }
i -= 1;
// Skip the middle digit when there are an odd number of digits.
if size % 2!= 0 {
num /= 10;
}
// Verify that the second half of the digits matches the first.
while i >= 0 {
let d = num % 10;
if d!= *digits.get(i as uint) {
return false;
}
num /= 10;
i -= 1;
}
true
}
pub fn solve() -... | num /= 10;
i += 1; | random_line_split |
problem_04.rs | // Copyright 2014 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 4
// Largest palindrome product
fn | (n: int) -> bool {
let size = (n as f64).log10().ceil() as int;
let mut num = n;
let mut digits = Vec::with_capacity((size/2) as uint);
let mut i = 0;
// Push the first half of the digits into the vector.
while i < size/2 {
digits.push(num % 10);
num /= 10;
i += 1;
}
i -= 1;
// Skip the middle digit when... | is_palindrome | identifier_name |
problem_04.rs | // Copyright 2014 Mitchell Kember. Subject to the MIT License.
// Project Euler: Problem 4
// Largest palindrome product
fn is_palindrome(n: int) -> bool | return false;
}
num /= 10;
i -= 1;
}
true
}
pub fn solve() -> int {
let mut largest = 0;
for a in range(100, 1000) {
for b in range(100, 1000) {
let c = a * b;
if c > largest && is_palindrome(c) {
largest = c;
}
}
}
largest
}
| {
let size = (n as f64).log10().ceil() as int;
let mut num = n;
let mut digits = Vec::with_capacity((size/2) as uint);
let mut i = 0;
// Push the first half of the digits into the vector.
while i < size/2 {
digits.push(num % 10);
num /= 10;
i += 1;
}
i -= 1;
// Skip the middle digit when there are an odd... | identifier_body |
enum4.rs | // enum4.rs
#[derive(Debug)]
enum Value {
Number(f64),
Str(String),
Bool(bool),
Arr(Vec<Value>)
}
use std::fmt;
impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Value::*;
match *self {
Number(n) => write!(f,"{} ",n),
... |
fn b(&mut self, v: bool) -> &mut Builder {
self.push(Value::Bool(v))
}
fn n(&mut self, v: f64) -> &mut Builder {
self.push(Value::Number(v))
}
fn extract_current(&mut self, arr: Vec<Value>) -> Vec<Value> {
let mut current = arr;
std::mem::swap(&mut current, &mut s... | {
self.push(Value::Str(s.to_string()))
} | identifier_body |
enum4.rs | // enum4.rs
#[derive(Debug)]
enum Value {
Number(f64),
Str(String),
Bool(bool),
Arr(Vec<Value>)
}
use std::fmt;
impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Value::*;
match *self {
Number(n) => write!(f,"{} ",n),
... | self.push(Value::Str(s.to_string()))
}
fn b(&mut self, v: bool) -> &mut Builder {
self.push(Value::Bool(v))
}
fn n(&mut self, v: f64) -> &mut Builder {
self.push(Value::Number(v))
}
fn extract_current(&mut self, arr: Vec<Value>) -> Vec<Value> {
let mut current ... | self
}
fn s(&mut self, s: &str) -> &mut Builder { | random_line_split |
enum4.rs | // enum4.rs
#[derive(Debug)]
enum Value {
Number(f64),
Str(String),
Bool(bool),
Arr(Vec<Value>)
}
use std::fmt;
impl fmt::Display for Value {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
use Value::*;
match *self {
Number(n) => write!(f,"{} ",n),
... | (&mut self, s: &str) -> &mut Builder {
self.push(Value::Str(s.to_string()))
}
fn b(&mut self, v: bool) -> &mut Builder {
self.push(Value::Bool(v))
}
fn n(&mut self, v: f64) -> &mut Builder {
self.push(Value::Number(v))
}
fn extract_current(&mut self, arr: Vec<Value>) -... | s | identifier_name |
lisp_attr.rs | use std::str::FromStr;
use syn;
use synom;
use function::{Function, LispFnType};
/// Arguments of the lisp_fn attribute.
pub struct LispFnArgs {
/// Desired Lisp name of the function.
/// If not given, derived as the Rust name with "_" -> "-".
pub name: String,
/// Desired C name of the related static... |
fn parse_kv(kv_list: Vec<(syn::Ident, syn::StrLit)>, function: &Function) -> LispFnArgs {
let mut name = None;
let mut c_name = None;
let mut intspec = None;
let mut min = match function.fntype {
LispFnType::Many => 0,
LispFnType::Normal(n) => n,
};
for (ident, string) in kv_li... | {
let kv = match parse_arguments(input) {
synom::IResult::Done(_, o) => o,
synom::IResult::Error => return Err("failed to parse `lisp_fn` arguments"),
};
Ok(parse_kv(kv, function))
} | identifier_body |
lisp_attr.rs | use std::str::FromStr;
use syn;
use synom;
use function::{Function, LispFnType};
/// Arguments of the lisp_fn attribute.
pub struct LispFnArgs {
/// Desired Lisp name of the function.
/// If not given, derived as the Rust name with "_" -> "-".
pub name: String,
/// Desired C name of the related static... | c_name: c_name.unwrap_or_else(|| function.name.to_string()),
min,
intspec,
}
}
named!(parse_arguments -> Vec<(syn::Ident, syn::StrLit)>,
opt_vec!(
do_parse!(
punct!("(")
>> args: separated_list!(punct!(","), key_value)
>> punct!(")")
... | }
LispFnArgs {
name: name.unwrap_or_else(|| function.name.to_string().replace("_", "-")), | random_line_split |
lisp_attr.rs | use std::str::FromStr;
use syn;
use synom;
use function::{Function, LispFnType};
/// Arguments of the lisp_fn attribute.
pub struct LispFnArgs {
/// Desired Lisp name of the function.
/// If not given, derived as the Rust name with "_" -> "-".
pub name: String,
/// Desired C name of the related static... | (input: &str, function: &Function) -> Result<LispFnArgs, &'static str> {
let kv = match parse_arguments(input) {
synom::IResult::Done(_, o) => o,
synom::IResult::Error => return Err("failed to parse `lisp_fn` arguments"),
};
Ok(parse_kv(kv, function))
}
fn parse_kv(kv_list: Vec<(syn::Ident... | parse | identifier_name |
mod.rs | /*!
Contains everything related to vertex buffers.
The main struct is the `VertexBuffer`, which represents a buffer in the video memory,
containing a list of vertices.
In order to create a vertex buffer, you must first create a struct that represents each vertex,
and implement the `glium::vertex::Vertex` trait on it.... | <'a> {
/// A buffer uploaded in the video memory.
///
/// If the second parameter is `Some`, then a fence *must* be sent with this sender for
/// when the buffer stops being used.
///
/// The third and fourth parameters are the offset and length of the buffer.
VertexBuffer(&'a VertexBufferAn... | VerticesSource | identifier_name |
mod.rs | /*!
Contains everything related to vertex buffers.
The main struct is the `VertexBuffer`, which represents a buffer in the video memory,
containing a list of vertices.
In order to create a vertex buffer, you must first create a struct that represents each vertex,
and implement the `glium::vertex::Vertex` trait on it.... | use std::iter::Chain;
use std::option::IntoIter;
pub use self::buffer::{VertexBuffer, VertexBufferAny, Mapping};
pub use self::buffer::{VertexBufferSlice, VertexBufferAnySlice};
pub use self::format::{AttributeType, VertexFormat};
pub use self::per_instance::{PerInstanceAttributesBuffer, PerInstanceAttributesBufferAny... | random_line_split | |
gpio_multithreaded_mutex.rs | // gpio_multithreaded_mutex.rs - Blinks an LED from multiple threads.
//
// Remember to add a resistor of an appropriate value in series, to prevent
// exceeding the maximum current rating of the GPIO pin and the LED.
use std::error::Error;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use rp... | pin.set_high();
thread::sleep(Duration::from_millis(250));
pin.set_low();
thread::sleep(Duration::from_millis(250));
// The MutexGuard is automatically dropped here.
}));
});
// Lock the Mutex on the main thread to get exclusive access to the ... | let mut pin = output_pin_clone.lock().unwrap();
println!("Blinking the LED from thread {}.", thread_id); | random_line_split |
gpio_multithreaded_mutex.rs | // gpio_multithreaded_mutex.rs - Blinks an LED from multiple threads.
//
// Remember to add a resistor of an appropriate value in series, to prevent
// exceeding the maximum current rating of the GPIO pin and the LED.
use std::error::Error;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use rp... | });
// Lock the Mutex on the main thread to get exclusive access to the OutputPin.
let mut pin = output_pin.lock().unwrap();
println!("Blinking the LED from the main thread.");
pin.set_high();
thread::sleep(Duration::from_millis(250));
pin.set_low();
thread::sleep(Duration::from_millis(... | {
// Retrieve the GPIO pin and configure it as an output.
let output_pin = Arc::new(Mutex::new(Gpio::new()?.get(GPIO_LED)?.into_output_low()));
// Populate a Vec with threads so we can call join() on them later.
let mut threads = Vec::with_capacity(NUM_THREADS);
(0..NUM_THREADS).for_each(|thread_id... | identifier_body |
gpio_multithreaded_mutex.rs | // gpio_multithreaded_mutex.rs - Blinks an LED from multiple threads.
//
// Remember to add a resistor of an appropriate value in series, to prevent
// exceeding the maximum current rating of the GPIO pin and the LED.
use std::error::Error;
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::Duration;
use rp... | () -> Result<(), Box<dyn Error>> {
// Retrieve the GPIO pin and configure it as an output.
let output_pin = Arc::new(Mutex::new(Gpio::new()?.get(GPIO_LED)?.into_output_low()));
// Populate a Vec with threads so we can call join() on them later.
let mut threads = Vec::with_capacity(NUM_THREADS);
(0.... | main | identifier_name |
reexports.rs | #![feature(decl_macro)]
pub macro addr_of($place:expr) {
&raw const $place
}
pub macro addr_of_crate($place:expr) {
&raw const $place
}
pub macro addr_of_super($place:expr) {
&raw const $place
}
pub macro addr_of_self($place:expr) {
&raw const $place
}
pub macro addr_of_local($place:expr) {
&ra... | ;
pub struct FooCrate;
pub struct FooSuper;
pub struct FooSelf;
pub struct FooLocal;
pub enum Bar { Foo, }
pub enum BarCrate { Foo, }
pub enum BarSuper { Foo, }
pub enum BarSelf { Foo, }
pub enum BarLocal { Foo, }
pub fn foo() {}
pub fn foo_crate() {}
pub fn foo_super() {}
pub fn foo_self() {}
pub fn foo_local() {}
... | Foo | identifier_name |
reexports.rs | #![feature(decl_macro)]
pub macro addr_of($place:expr) {
&raw const $place
}
pub macro addr_of_crate($place:expr) {
&raw const $place
}
pub macro addr_of_super($place:expr) {
&raw const $place
}
pub macro addr_of_self($place:expr) {
&raw const $place
}
pub macro addr_of_local($place:expr) {
&ra... | pub type Type = i32;
pub type TypeCrate = i32;
pub type TypeSuper = i32;
pub type TypeSelf = i32;
pub type TypeLocal = i32;
pub union Union {
a: i8,
b: i8,
}
pub union UnionCrate {
a: i8,
b: i8,
}
pub union UnionSuper {
a: i8,
b: i8,
}
pub union UnionSelf {
a: i8,
b: i8,
}
pub union Uni... | random_line_split | |
usart3.rs | //! Test the USART3 instance
//!
//! Connect the TX and RX pins to run this test
#![feature(const_fn)]
#![feature(used)]
#![no_std]
extern crate blue_pill;
extern crate embedded_hal as hal;
// version = "0.2.3"
extern crate cortex_m_rt;
// version = "0.1.0"
#[macro_use]
extern crate cortex_m_rtfm as rtfm;
extern ... |
// TASKS
tasks!(stm32f103xx, {});
| {
// OK
rtfm::bkpt();
// Sleep
loop {
rtfm::wfi();
}
} | identifier_body |
usart3.rs | //! Test the USART3 instance
//!
//! Connect the TX and RX pins to run this test
#![feature(const_fn)]
#![feature(used)]
#![no_std]
extern crate blue_pill;
extern crate embedded_hal as hal;
// version = "0.2.3"
extern crate cortex_m_rt;
// version = "0.1.0"
#[macro_use]
extern crate cortex_m_rtfm as rtfm;
extern ... | (_prio: P0, _thr: T0) ->! {
// OK
rtfm::bkpt();
// Sleep
loop {
rtfm::wfi();
}
}
// TASKS
tasks!(stm32f103xx, {});
| idle | identifier_name |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.