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
task-spawn-barefn.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
{ assert!("Ensure that the child thread runs by panicking".is_empty()); }
identifier_body
task-spawn-barefn.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
} fn startfn() { assert!("Ensure that the child thread runs by panicking".is_empty()); }
{ panic!() }
conditional_block
methods.rs
// aux-build:option_helpers.rs #![warn(clippy::all, clippy::pedantic)] #![allow( clippy::blacklisted_name, clippy::default_trait_access, clippy::missing_docs_in_private_items, clippy::missing_safety_doc, clippy::non_ascii_literal, clippy::new_without_default, clippy::needless_pass_by_value,...
impl BadNew { fn new() -> i32 { 0 } } struct T; impl Mul<T> for T { type Output = T; // No error, obviously. fn mul(self, other: T) -> T { self } } /// Checks implementation of `FILTER_NEXT` lint. #[rustfmt::skip] fn filter_next() { let v = vec![3, 2, 1, 0, -1, -2, -3]; ...
random_line_split
methods.rs
// aux-build:option_helpers.rs #![warn(clippy::all, clippy::pedantic)] #![allow( clippy::blacklisted_name, clippy::default_trait_access, clippy::missing_docs_in_private_items, clippy::missing_safety_doc, clippy::non_ascii_literal, clippy::new_without_default, clippy::needless_pass_by_value,...
l BadNew { fn new() -> i32 { 0 } } struct T; impl Mul<T> for T { type Output = T; // No error, obviously. fn mul(self, other: T) -> T { self } } /// Checks implementation of `FILTER_NEXT` lint. #[rustfmt::skip] fn filter_next() { let v = vec![3, 2, 1, 0, -1, -2, -3]; ...
; imp
identifier_name
font_template.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 app_units::Au; use core_graphics::data_provider::CGDataProvider; use core_graphics::font::CGFont; use core_tex...
} impl<'de> Deserialize<'de> for CachedCTFont { fn deserialize<D>(deserializer: D) -> Result<CachedCTFont, D::Error> where D: Deserializer<'de> { struct NoneOptionVisitor; impl<'de> Visitor<'de> for NoneOptionVisitor { type Value = CachedCTFont; fn e...
{ serializer.serialize_none() }
identifier_body
font_template.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 app_units::Au; use core_graphics::data_provider::CGDataProvider; use core_graphics::font::CGFont; use core_tex...
} }
} } deserializer.deserialize_option(NoneOptionVisitor)
random_line_split
font_template.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 app_units::Au; use core_graphics::data_provider::CGDataProvider; use core_graphics::font::CGFont; use core_tex...
<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer { serializer.serialize_none() } } impl<'de> Deserialize<'de> for CachedCTFont { fn deserialize<D>(deserializer: D) -> Result<CachedCTFont, D::Error> where D: Deserializer<'de> { struct NoneOptionVisit...
serialize
identifier_name
main.rs
#![deny(warnings)] #![deny(unused_import_braces, unused_qualifications)] #[macro_use] extern crate log; extern crate clap; extern crate env_logger; extern crate breeze_core; extern crate breeze_backends; extern crate breeze_backend; mod input; use input::attach_default_input; use breeze_core::rom::Rom; use breeze_...
(args: &ArgMatches) -> Result<(), Box<Error>> { if args.value_of("record").is_some() && args.value_of("replay").is_some() { return Err("`record` and `replay` may not be specified together!".into()); } let renderer_name = args.value_of("renderer").unwrap_or(&breeze_backends::DEFAULT_RENDERER); ...
process_args
identifier_name
main.rs
#![deny(warnings)] #![deny(unused_import_braces, unused_qualifications)] #[macro_use] extern crate log; extern crate clap; extern crate env_logger; extern crate breeze_core; extern crate breeze_backends; extern crate breeze_backend; mod input; use input::attach_default_input; use breeze_core::rom::Rom; use breeze_...
.long("replay") .takes_value(true) .help("Replay a recording from a text file")); // Add debugging options if cfg!(debug_assertions) { app = app.arg(clap::Arg::with_name("oneframe") .long("oneframe") .help("Render a single frame, then pause")); ...
.arg(clap::Arg::with_name("record") .long("record") .takes_value(true) .help("Record input to a text file")) .arg(clap::Arg::with_name("replay")
random_line_split
main.rs
#![deny(warnings)] #![deny(unused_import_braces, unused_qualifications)] #[macro_use] extern crate log; extern crate clap; extern crate env_logger; extern crate breeze_core; extern crate breeze_backends; extern crate breeze_backend; mod input; use input::attach_default_input; use breeze_core::rom::Rom; use breeze_...
.short("A") .long("audio") .takes_value(true) .help("The audio backend to use")) .arg(clap::Arg::with_name("savestate") .long("savestate") .takes_value(true) .help("The save state file to load")) .arg(clap::Arg::with_name("record...
{ if env::var_os("RUST_LOG").is_none() { env::set_var("RUST_LOG", "breeze=INFO"); } env_logger::init().unwrap(); let mut app = clap::App::new("breeze") .version(env!("CARGO_PKG_VERSION")) .about("SNES emulator") .arg(clap::Arg::with_name("rom") .required(true...
identifier_body
proof.rs
use crate::services::ledger::merkletree::tree::{Tree, TreeLeafData}; use indy_utils::crypto::hash::Hash; use indy_api_types::errors::prelude::*; /// An inclusion proof represent the fact that a `value` is a member /// of a `MerkleTree` with root hash `root_hash`. #[derive(Clone, Debug)] pub struct Proof { /// The ...
fn new_leaf_proof(hash: &[u8], needle: &[u8]) -> Option<Lemma> { if *hash == *needle { Some(Lemma { node_hash: hash.into(), sibling_hash: None, sub_lemma: None }) } else { None } } fn new_tree_proo...
{ match *tree { Tree::Empty {.. } => None, Tree::Leaf { ref hash, .. } => Lemma::new_leaf_proof(hash, needle), Tree::Node { ref hash, ref left, ref right } => Lemma::new_tree_proof(hash, needle, left, right) } }
identifier_body
proof.rs
use crate::services::ledger::merkletree::tree::{Tree, TreeLeafData}; use indy_utils::crypto::hash::Hash; use indy_api_types::errors::prelude::*; /// An inclusion proof represent the fact that a `value` is a member /// of a `MerkleTree` with root hash `root_hash`. #[derive(Clone, Debug)] pub struct Proof { /// The ...
(root_hash: Vec<u8>, lemma: Lemma, value: TreeLeafData) -> Self { Proof { root_hash, lemma, value } } /// Checks whether this inclusion proof is well-formed, /// and whether its root hash matches the given `root_hash`. pub fn validate(&self, root_hash...
new
identifier_name
proof.rs
use crate::services::ledger::merkletree::tree::{Tree, TreeLeafData}; use indy_utils::crypto::hash::Hash; use indy_api_types::errors::prelude::*; /// An inclusion proof represent the fact that a `value` is a member /// of a `MerkleTree` with root hash `root_hash`. #[derive(Clone, Debug)] pub struct Proof { /// The ...
match lemma.sibling_hash { None => Ok(false), Some(Positioned::Left(ref hash)) => { let combined = Hash::hash_nodes(hash, &sub.node_hash)?; let hashes_match = combined.to_vec().as_slice() == ...
None => Ok(lemma.sibling_hash.is_none()), Some(ref sub) =>
random_line_split
number.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
#[link(name = "CoreFoundation", kind = "framework")] extern { /* * CFNumber.h */ fn CFNumberCreate(allocator: CFAllocatorRef, theType: CFNumberType, valuePtr: *c_void) -> CFNumberRef; //fn CFNumberGetByteSize fn CFNumberGetValue(number: CFNumberRef, theType: CFNumberType...
{ FromPrimitive::from_i64(value).unwrap() }
identifier_body
number.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
(&self) -> Option<i64> { unsafe { let mut value: i64 = 0; let ok = CFNumberGetValue(self.obj, kCFNumberSInt64Type, cast::transmute(&mut value)); assert!(ok); Some(value) } } #[inline] fn to_u64(&self) -> Option<u64> { // CFNumber does ...
to_i64
identifier_name
number.rs
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at ...
#[inline] fn from_f64(value: f64) -> Option<CFNumber> { unsafe { let number_ref = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloat64Type, cast::transmute(&value)); Some(TCFType::wrap_under_c...
random_line_split
main.rs
//! The N-body benchmark from the [benchmarks game][bg]. //! //! [bg]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html#nbody #![deny(warnings, rust_2018_idioms)] fn run<O: std::io::Write>(o: &mut O, n: usize, alg: usize) { let (energy_before, energy_after) = nbody_lib::run(n, alg...
} } #[test] fn verify_output_scalar() { let mut out: Vec<u8> = Vec::new(); run(&mut out, 1000, 1); assert_eq!(out.len(), OUTPUT.len()); if out!= OUTPUT { for i in 0..out.len() { assert_eq!( out[i], OUTPUT[i], ...
}
random_line_split
main.rs
//! The N-body benchmark from the [benchmarks game][bg]. //! //! [bg]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html#nbody #![deny(warnings, rust_2018_idioms)] fn run<O: std::io::Write>(o: &mut O, n: usize, alg: usize) { let (energy_before, energy_after) = nbody_lib::run(n, alg...
else { 1 // SIMD algorithm }; run(&mut std::io::stdout(), n, alg); } #[cfg(test)] mod tests { use super::*; static OUTPUT: &'static [u8] = include_bytes!("nbody-output.txt"); #[test] fn verify_output_simd() { let mut out: Vec<u8> = Vec::new(); run(&mut out, 1000, 0); ...
{ v.parse().expect("second argument must be a usize") }
conditional_block
main.rs
//! The N-body benchmark from the [benchmarks game][bg]. //! //! [bg]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html#nbody #![deny(warnings, rust_2018_idioms)] fn run<O: std::io::Write>(o: &mut O, n: usize, alg: usize) { let (energy_before, energy_after) = nbody_lib::run(n, alg...
}
{ let mut out: Vec<u8> = Vec::new(); run(&mut out, 1000, 1); assert_eq!(out.len(), OUTPUT.len()); if out != OUTPUT { for i in 0..out.len() { assert_eq!( out[i], OUTPUT[i], "byte {} differs - is: {:#08b} - should: {:#08...
identifier_body
main.rs
//! The N-body benchmark from the [benchmarks game][bg]. //! //! [bg]: https://benchmarksgame-team.pages.debian.net/benchmarksgame/description/nbody.html#nbody #![deny(warnings, rust_2018_idioms)] fn
<O: std::io::Write>(o: &mut O, n: usize, alg: usize) { let (energy_before, energy_after) = nbody_lib::run(n, alg); writeln!(o, "{:.9}", energy_before); writeln!(o, "{:.9}", energy_after); } fn main() { let n: usize = std::env::args() .nth(1) .expect("need one arg") .parse() ...
run
identifier_name
autogen.rs
// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may n...
// software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. //! Thrift compiler auto-generated support. //! //! //! T...
random_line_split
lib.rs
// Copyright 2014-2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
//! //! # Pay for what you use //! //! With respect to searching text with a regular expression, there are three //! questions that can be asked: //! //! 1. Does the text match this expression? //! 2. If so, where does it match? //! 3. Where are the submatches? //! //! Generally speaking, this crate could provide a fun...
//! let before = "2012-03-14, 2013-01-01 and 2014-07-05"; //! let after = re.replace_all(before, "$m/$d/$y"); //! assert_eq!(after, "03/14/2012, 01/01/2013 and 07/05/2014"); //! # } //! ```
random_line_split
code_flow_blob.rs
use azure_sdk_auth_aad::*; use oauth2::{ClientId, ClientSecret, TokenResponse}; use std::env; use std::error::Error; use url::Url; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>> { let client_id = ClientId::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID environment variable.")); let c...
let dt = chrono::Utc::now(); let time = format!("{}", dt.format("%a, %d %h %Y %T GMT")); println!("x-ms-date ==> {}", time); let resp = reqwest::Client::new() .get(&format!( "https://{}.blob.core.windows.net/{}?restype=container&comp=list", storage_account_name, container...
println!("token received: {:?}", token); println!("token secret: {}", token.access_token().secret());
random_line_split
code_flow_blob.rs
use azure_sdk_auth_aad::*; use oauth2::{ClientId, ClientSecret, TokenResponse}; use std::env; use std::error::Error; use url::Url; #[tokio::main] async fn main() -> Result<(), Box<dyn Error>>
Url::parse("http://localhost:3003/redirect").unwrap(), &format!( "https://{}.blob.core.windows.net/user_impersonation", storage_account_name ), ); println!("c == {:?}", c); println!("\nbrowse this url:\n{}", c.authorize_url); // Start a naive server to r...
{ let client_id = ClientId::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID environment variable.")); let client_secret = ClientSecret::new( env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET environment variable."), ); let tenant_id = env::var("TENANT_ID").expect("Missing TENAN...
identifier_body
code_flow_blob.rs
use azure_sdk_auth_aad::*; use oauth2::{ClientId, ClientSecret, TokenResponse}; use std::env; use std::error::Error; use url::Url; #[tokio::main] async fn
() -> Result<(), Box<dyn Error>> { let client_id = ClientId::new(env::var("CLIENT_ID").expect("Missing CLIENT_ID environment variable.")); let client_secret = ClientSecret::new( env::var("CLIENT_SECRET").expect("Missing CLIENT_SECRET environment variable."), ); let tenant_id = env::var("...
main
identifier_name
selection.rs
use std::ptr; use std::mem; use std::vec::Vec; /// Implementation of selection sort. /// CLRS pg 29. `O(n^2)`. pub fn selection_sort<T: Ord>(mut a: Vec<T>) -> Vec<T> { let len = a.len(); let cap = a.capacity(); let p = a.as_mut_ptr(); unsafe { mem::forget(a); for j in range(0, (len - 1)...
} Vec::from_raw_parts(len, cap, p) } } #[cfg(test)] mod tests { use sorting; #[test] fn test_selection_sort_example() { // Example from CLRS pg 18 (originally for insertion sort). let mut sorted = vec!(5i32, 2, 4, 6, 1, 3); sorted = sorting::selection_sort(sorte...
{ ptr::swap(p.offset(smallest), p.offset(j)); }
conditional_block
selection.rs
use std::ptr; use std::mem; use std::vec::Vec; /// Implementation of selection sort. /// CLRS pg 29. `O(n^2)`. pub fn selection_sort<T: Ord>(mut a: Vec<T>) -> Vec<T> { let len = a.len(); let cap = a.capacity(); let p = a.as_mut_ptr(); unsafe { mem::forget(a); for j in range(0, (len - 1)...
}
{ let mut sorted = vec!(); sorted = sorting::selection_sort::<i32>(sorted); assert_eq!(sorted, vec!()); }
identifier_body
selection.rs
use std::ptr; use std::mem; use std::vec::Vec; /// Implementation of selection sort. /// CLRS pg 29. `O(n^2)`. pub fn selection_sort<T: Ord>(mut a: Vec<T>) -> Vec<T> { let len = a.len(); let cap = a.capacity(); let p = a.as_mut_ptr(); unsafe { mem::forget(a); for j in range(0, (len - 1)...
} #[cfg(test)] mod tests { use sorting; #[test] fn test_selection_sort_example() { // Example from CLRS pg 18 (originally for insertion sort). let mut sorted = vec!(5i32, 2, 4, 6, 1, 3); sorted = sorting::selection_sort(sorted); assert_eq!(sorted, vec!(1i32, 2, 3, 4, 5, 6));...
} } Vec::from_raw_parts(len, cap, p) }
random_line_split
selection.rs
use std::ptr; use std::mem; use std::vec::Vec; /// Implementation of selection sort. /// CLRS pg 29. `O(n^2)`. pub fn selection_sort<T: Ord>(mut a: Vec<T>) -> Vec<T> { let len = a.len(); let cap = a.capacity(); let p = a.as_mut_ptr(); unsafe { mem::forget(a); for j in range(0, (len - 1)...
() { let mut sorted = vec!(); sorted = sorting::selection_sort::<i32>(sorted); assert_eq!(sorted, vec!()); } }
test_selection_sort_empty
identifier_name
service.rs
use tokio_io::codec::{Encoder, Decoder, Framed}; use tokio_proto::multiplex::RequestId; use bytes::BytesMut; use bytes::BigEndian; use std::str; use std::io::Error as IOError; use bytes::buf::IntoBuf; use bytes::Buf; use bytes::BufMut; use tokio_proto::multiplex::ServerProto; use tokio_io::{AsyncRead, AsyncWrite}; use ...
; pub struct SiderRequest { data: String } pub struct SiderReponse { data: String } impl Decoder for SiderCodec { type Item = (RequestId, SiderRequest); type Error = SiderError; fn decode(&mut self, src: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> { if src.len() < 10 { ...
SiderService
identifier_name
service.rs
use tokio_io::codec::{Encoder, Decoder, Framed}; use tokio_proto::multiplex::RequestId; use bytes::BytesMut; use bytes::BigEndian; use std::str; use std::io::Error as IOError; use bytes::buf::IntoBuf; use bytes::Buf; use bytes::BufMut; use tokio_proto::multiplex::ServerProto; use tokio_io::{AsyncRead, AsyncWrite}; use ...
} } impl Encoder for SiderCodec { type Item = (RequestId, SiderReponse); type Error = SiderError; fn encode(&mut self, msg: Self::Item, buf: &mut BytesMut) -> Result<(), Self::Error> { let (id, msg) = msg; buf.put_u64::<BigEndian>(id); buf.put_u16::<BigEndian>(msg.data.len() a...
{ Ok(None) }
conditional_block
service.rs
use tokio_io::codec::{Encoder, Decoder, Framed}; use tokio_proto::multiplex::RequestId; use bytes::BytesMut; use bytes::BigEndian; use std::str; use std::io::Error as IOError; use bytes::buf::IntoBuf; use bytes::Buf; use bytes::BufMut; use tokio_proto::multiplex::ServerProto; use tokio_io::{AsyncRead, AsyncWrite}; use ...
} } impl Service for SiderService { type Request = SiderRequest; type Response = SiderReponse; type Error = SiderError; type Future = BoxFuture<Self::Response, Self::Error>; fn call(&self, req: Self::Request) -> Self::Future { future::ok(SiderReponse { data: req.data } ).boxed() } ...
type BindTransport = Result<Self::Transport, IOError>; fn bind_transport(&self, io: T) -> Self::BindTransport { Ok(io.framed(SiderCodec))
random_line_split
t_test.rs
use error::Error; use summary::Summary; /// The results and parameters of a two-sided, unequal-variances t-test. pub struct TTest { pub p: f64, pub t: f64, pub df: f64, } fn t_test_2_sided(t: f64, df: f64) -> Result<TTest, Error> { let p = 1.0 - t_atv(t.abs(), df as f64)?; Ok(TTest { df, p, t })...
/// The definite integral of the density function of Student's t-distribution /// over an interval [-t, t]. Also called the A(t|ν) function. /// /// See equation 6.4.9 in [1]. /// /// [1]: "Numerical Recipes in C", 2nd Ed., p. 228 fn t_atv(t: f64, df: f64) -> Result<f64, Error> { use num; let x = df / (df + ...
{ let df1 = n1 - 1.0; let df2 = n2 - 1.0; let num = ((var1 / n1) + (var2 / n2)).powi(2); let den = var1.powi(2) / (n1.powi(2) * df1) + var2.powi(2) / (n2.powi(2) * df2); let appx = num / den; appx }
identifier_body
t_test.rs
use error::Error; use summary::Summary; /// The results and parameters of a two-sided, unequal-variances t-test. pub struct TTest { pub p: f64, pub t: f64, pub df: f64, } fn t_test_2_sided(t: f64, df: f64) -> Result<TTest, Error> { let p = 1.0 - t_atv(t.abs(), df as f64)?; Ok(TTest { df, p, t })...
t: f64, df: f64) -> Result<f64, Error> { use num; let x = df / (df + t.powi(2)); let a = 0.5 * df; let b = 0.5; let ib = num::inc_beta(x, a, b)?; Ok(1.0 - ib) }
_atv(
identifier_name
t_test.rs
use error::Error; use summary::Summary; /// The results and parameters of a two-sided, unequal-variances t-test. pub struct TTest { pub p: f64, pub t: f64, pub df: f64, } fn t_test_2_sided(t: f64, df: f64) -> Result<TTest, Error> { let p = 1.0 - t_atv(t.abs(), df as f64)?; Ok(TTest { df, p, t })...
} /// Degrees of freedom, approximated using the Welch-Satterthwaite equation [1]. /// /// [1]: http://www.itl.nist.gov/div898/handbook/mpc/section5/mpc571.htm fn welch_satterthwaite_df(var1: f64, n1: f64, var2: f64, n2: f64) -> f64 { let df1 = n1 - 1.0; let df2 = n2 - 1.0; let num = ((var1 / n1) + (var2 ...
let t = (m1 - m2) / s_delta_bar; let df = welch_satterthwaite_df(var1, n1, var2, n2); (t, df)
random_line_split
net.rs
//! A chat server that broadcasts a message to all connections. //! //! This example is explicitly more verbose than it has to be. This is to //! illustrate more concepts. //! //! A chat server for telnet clients. After a telnet client connects, the first //! line should contain the client's name. After that, all lines...
<'a, R, W>(reader: R, writer: W) -> SppHandle<'a, R, W> where R: AsyncRead, W: AsyncWrite { SppHandle { reader, writer, mapper: libspp::mapper::new(), } } #[derive(Debug)] pub struct SppHandle<'a, R, W> { reader: Option<R>, writer: Option<W>, mapper: SppMapper<...
new_spp_handle
identifier_name
net.rs
//! A chat server that broadcasts a message to all connections. //! //! This example is explicitly more verbose than it has to be. This is to //! illustrate more concepts. //! //! A chat server for telnet clients. After a telnet client connects, the first //! line should contain the client's name. After that, all lines...
} #[test] pub fn main() { let address = "127.0.0.1:6142".parse().unwrap(); let listener = TcpListener::bind(&address).unwrap(); println!("server running on localhost:6142"); let server = listener.incoming().for_each(move |stream| { let address = stream.peer_addr().unwrap(); println...
{ loop { } }
identifier_body
net.rs
//! A chat server that broadcasts a message to all connections. //! //! This example is explicitly more verbose than it has to be. This is to //! illustrate more concepts. //! //! A chat server for telnet clients. After a telnet client connects, the first //! line should contain the client's name. After that, all lines...
writer, mapper: libspp::mapper::new(), } } #[derive(Debug)] pub struct SppHandle<'a, R, W> { reader: Option<R>, writer: Option<W>, mapper: SppMapper<'a> } impl<R, W> Future for SppHandle<R, W> where R: AsyncRead, W: AsyncWrite, { type Item = (R, W); type Error = i...
where R: AsyncRead, W: AsyncWrite { SppHandle { reader,
random_line_split
utils.rs
//! //! Various utility functions used throughout Conrod. //! use num::{Float, NumCast, PrimInt, ToPrimitive}; use position::{Dimensions, Point}; use vecmath::vec2_sub; /// Clamp a value between a given min and max. pub fn
<T: PartialOrd>(n: T, min: T, max: T) -> T { if n < min { min } else if n > max { max } else { n } } /// Return whether or not a given point is over a rectangle at a given point on a cartesian plane. pub fn is_over_rect(rect_point: Point, mouse_point: Point, rect_dim: Dimensions) -> bool { let point = vec2_sub...
clamp
identifier_name
utils.rs
//! //! Various utility functions used throughout Conrod. //! use num::{Float, NumCast, PrimInt, ToPrimitive}; use position::{Dimensions, Point}; use vecmath::vec2_sub; /// Clamp a value between a given min and max. pub fn clamp<T: PartialOrd>(n: T, min: T, max: T) -> T { if n < min { min } else if n > max { ma...
/// Get a suitable string from the value, its max and the pixel range. pub fn val_to_string<T: ToString + NumCast> (val: T, max: T, val_rng: T, pixel_range: usize) -> String { let mut s = val.to_string(); let decimal = s.chars().position(|ch| ch == '.'); match decimal { None => s, Some(idx...
{ let val_f: f64 = NumCast::from(val).unwrap(); let in_min_f: f64 = NumCast::from(in_min).unwrap(); let in_max_f: f64 = NumCast::from(in_max).unwrap(); let out_min_f: f64 = NumCast::from(out_min).unwrap(); let out_max_f: f64 = NumCast::from(out_max).unwrap(); NumCast::from( (val_f - in_m...
identifier_body
utils.rs
//! //! Various utility functions used throughout Conrod. //! use num::{Float, NumCast, PrimInt, ToPrimitive}; use position::{Dimensions, Point}; use vecmath::vec2_sub; /// Clamp a value between a given min and max. pub fn clamp<T: PartialOrd>(n: T, min: T, max: T) -> T { if n < min { min } else if n > max { ma...
/// Map a value from a given range to a new given range. pub fn map_range<X: Float + NumCast, Y: Float + NumCast> (val: X, in_min: X, in_max: X, out_min: Y, out_max: Y) -> Y { let val_f: f64 = NumCast::from(val).unwrap(); let in_min_f: f64 = NumCast::from(in_min).unwrap(); let in_max_f: f64 = NumCast::from(...
random_line_split
utils.rs
//! //! Various utility functions used throughout Conrod. //! use num::{Float, NumCast, PrimInt, ToPrimitive}; use position::{Dimensions, Point}; use vecmath::vec2_sub; /// Clamp a value between a given min and max. pub fn clamp<T: PartialOrd>(n: T, min: T, max: T) -> T { if n < min
else if n > max { max } else { n } } /// Return whether or not a given point is over a rectangle at a given point on a cartesian plane. pub fn is_over_rect(rect_point: Point, mouse_point: Point, rect_dim: Dimensions) -> bool { let point = vec2_sub(rect_point, mouse_point); if point[0].abs() < rect_dim[0] / 2....
{ min }
conditional_block
future-proofing-locals.rs
// edition:2018 #![allow(non_camel_case_types)] #![allow(unused_imports)] mod T { pub struct U; } mod x { pub struct y; } fn type_param<T>() { use T as _; //~ ERROR imports cannot refer to type parameters use T::U; //~ ERROR imports cannot refer to type parameters use T::*; //~ ERROR imports cann...
<T>() { let x = 10; use {T as _, x}; //~ ERROR imports cannot refer to type parameters //~| ERROR imports cannot refer to local variables } fn main() {}
nested
identifier_name
future-proofing-locals.rs
// edition:2018 #![allow(non_camel_case_types)] #![allow(unused_imports)] mod T { pub struct U; } mod x { pub struct y; } fn type_param<T>() { use T as _; //~ ERROR imports cannot refer to type parameters use T::U; //~ ERROR imports cannot refer to type parameters use T::*; //~ ERROR imports cann...
fn main() {}
{ let x = 10; use {T as _, x}; //~ ERROR imports cannot refer to type parameters //~| ERROR imports cannot refer to local variables }
identifier_body
future-proofing-locals.rs
// edition:2018 #![allow(non_camel_case_types)] #![allow(unused_imports)] mod T { pub struct U;
} mod x { pub struct y; } fn type_param<T>() { use T as _; //~ ERROR imports cannot refer to type parameters use T::U; //~ ERROR imports cannot refer to type parameters use T::*; //~ ERROR imports cannot refer to type parameters } fn self_import<T>() { use T; //~ ERROR imports cannot refer to type...
random_line_split
style.rs
use conrod::color::{TRANSPARENT, WHITE}; use conrod::widget::Button; /// Set the button style to a one that looks :+1: on the canvas. /// /// # Examples /// /// ``` /// # extern crate poke_a_mango; /// # extern crate conrod; /// # use poke_a_mango::ops::set_button_style; /// # use conrod::widget::{Button, Id}; /// # ...
<S>(button: &mut Button<S>) { button.style.color = Some(TRANSPARENT); button.style.border = None; button.style.border_color = Some(TRANSPARENT); button.style.label_color = Some(WHITE); }
set_button_style
identifier_name
style.rs
use conrod::color::{TRANSPARENT, WHITE}; use conrod::widget::Button; /// Set the button style to a one that looks :+1: on the canvas. /// /// # Examples /// /// ``` /// # extern crate poke_a_mango; /// # extern crate conrod; /// # use poke_a_mango::ops::set_button_style; /// # use conrod::widget::{Button, Id}; /// # ...
{ button.style.color = Some(TRANSPARENT); button.style.border = None; button.style.border_color = Some(TRANSPARENT); button.style.label_color = Some(WHITE); }
identifier_body
style.rs
use conrod::color::{TRANSPARENT, WHITE}; use conrod::widget::Button; /// Set the button style to a one that looks :+1: on the canvas. /// /// # Examples /// /// ``` /// # extern crate poke_a_mango; /// # extern crate conrod; /// # use poke_a_mango::ops::set_button_style;
/// # let mut ui = UiBuilder::new([1.0, 2.0]).build(); /// # let mut ui_widgets = ui.set_widgets(); /// # let buttid = Id::new(1); /// let mut butan = Button::new(); /// // Probably more positioning options /// set_button_style(&mut butan); /// /// butan.set(buttid, &mut ui_widgets); /// # } /// ``` pub fn set_button_s...
/// # use conrod::widget::{Button, Id}; /// # use conrod::{UiBuilder, Widget}; /// # fn main() {
random_line_split
blockdev.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 dbus; use dbus::arg::IterAppend; use dbus::tree::{ Access, EmitsChangedSignal, Factory, MTFn, MethodErr, Meth...
}; Ok(vec![msg]) } /// Get a blockdev property and place it on the D-Bus. The property is /// found by means of the getter method which takes a reference to a /// blockdev and obtains the property from the blockdev. fn get_blockdev_property<F, R>( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>,...
{ let (rc, rs) = engine_to_dbus_err_tuple(&err); return_message.append3(default_return, rc, rs) }
conditional_block
blockdev.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 dbus; use dbus::arg::IterAppend; use dbus::tree::{ Access, EmitsChangedSignal, Factory, MTFn, MethodErr, Meth...
fn get_blockdev_hardware_info( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>, ) -> Result<(), MethodErr> { get_blockdev_property(i, p, |_, p| Ok(p.hardware_info().unwrap_or("").to_owned())) } fn get_blockdev_user_info( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>, ) -> Result<(), Me...
get_blockdev_property(i, p, |_, p| Ok(format!("{}", p.devnode().display()))) }
random_line_split
blockdev.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 dbus; use dbus::arg::IterAppend; use dbus::tree::{ Access, EmitsChangedSignal, Factory, MTFn, MethodErr, Meth...
( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>, ) -> Result<(), MethodErr> { get_blockdev_property(i, p, |_, p| Ok(format!("{}", *p.size()))) } fn get_blockdev_state( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>, ) -> Result<(), MethodErr> { get_blockdev_property(i, p, |_, p| Ok...
get_blockdev_physical_size
identifier_name
blockdev.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 dbus; use dbus::arg::IterAppend; use dbus::tree::{ Access, EmitsChangedSignal, Factory, MTFn, MethodErr, Meth...
fn get_blockdev_initialization_time( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>, ) -> Result<(), MethodErr> { get_blockdev_property(i, p, |_, p| Ok(p.initialization_time().timestamp() as u64)) } fn get_blockdev_physical_size( i: &mut IterAppend, p: &PropInfo<MTFn<TData>, TData>, ) -> Re...
{ get_blockdev_property(i, p, |_, p| Ok(p.user_info().unwrap_or("").to_owned())) }
identifier_body
common.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
tag_ast = 0x32, tag_tree = 0x33, tag_id_range = 0x34, tag_table = 0x35, tag_table_id = 0x36, tag_table_val = 0x37, tag_table_def = 0x38, tag_table_node_type = 0x39, tag_table_node_type_subst = 0x3a, tag_table_freevars = 0x3b, tag_table_tcache = 0x3c, tag_table_param_de...
pub enum astencode_tag { // Reserves 0x32 -- 0x45
random_line_split
common.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
{ // Reserves 0x32 -- 0x45 tag_ast = 0x32, tag_tree = 0x33, tag_id_range = 0x34, tag_table = 0x35, tag_table_id = 0x36, tag_table_val = 0x37, tag_table_def = 0x38, tag_table_node_type = 0x39, tag_table_node_type_subst = 0x3a, tag_table_freevars = 0x3b, tag_table_tcache = ...
astencode_tag
identifier_name
common.rs
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MI...
else { Some(unsafe { cast::transmute(value) }) } } } pub static tag_item_trait_method_sort: uint = 0x46; pub static tag_item_impl_type_basename: uint = 0x47; // Language items are a top-level directory (for speed). Hierarchy: // // tag_lang_items // - tag_lang_items_item // - tag_lang_item...
{ None }
conditional_block
bucket_sort.rs
/// 桶排序 /// 时间复杂度:O(n), 稳定排序 // 桶排序 pub fn bucket_sort(mut nums: Vec<i32>, step: i32) -> Vec<i32> { let (mut min, mut max) = (nums[0], nums[0]); for i in 0..nums.len() { if min > nums[i] { min = nums[i]; } if max < nums[i] { max = nums[i]; } } // 设置需要的桶的数量 let bucket_num = (max - mi...
, end: usize) { if start >= end { return; } // 分区点 let pivot = partition(nums, start, end); if pivot!= 0 { quick_sort_internally(nums, start, pivot-1); } quick_sort_internally(nums, pivot+1, end); } fn partition(nums: &mut Vec<i32>, start: usize, end: usize) -> usize { let pivot = ...
2>, start: usize
conditional_block
bucket_sort.rs
/// 桶排序 /// 时间复杂度:O(n), 稳定排序 // 桶排序 pub fn bucket_sort(mut nums: Vec<i32>, step: i32) -> Vec<i32> { let (mut min, mut max) = (nums[0], nums[0]); for i in 0..nums.len() { if min > nums[i] { min = nums[i]; } if max < nums[i] { max = nums[i]; } } // 设置需要的桶的数量 let bucket_num = (max - mi...
let nums = vec![2, 5, 3, 0, 2, 3, 0, 3]; let m = bucket_sort(nums, 3); println!("{:?}", m); }
() {
identifier_name
bucket_sort.rs
/// 桶排序 /// 时间复杂度:O(n), 稳定排序 // 桶排序 pub fn bucket_sort(mut nums: Vec<i32>, step: i32) -> Vec<i32> { let (mut min, mut max) = (nums[0], nums[0]); for i in 0..nums.len() { if min > nums[i] { min = nums[i]; } if max < nums[i] { max = nums[i]; } } // 设置需要的桶的数量 let bucket_num = (max - mi...
main() { let nums = vec![2, 5, 3, 0, 2, 3, 0, 3]; let m = bucket_sort(nums, 3); println!("{:?}", m); }
+= 1; } } swap(nums, i, end); i } fn swap(nums: &mut Vec<i32>, i: usize, j: usize) { if i == j { return; } let tmp = nums[i]; nums[i] = nums[j]; nums[j] = tmp; } fn
identifier_body
bucket_sort.rs
/// 桶排序 /// 时间复杂度:O(n), 稳定排序 // 桶排序 pub fn bucket_sort(mut nums: Vec<i32>, step: i32) -> Vec<i32> { let (mut min, mut max) = (nums[0], nums[0]); for i in 0..nums.len() { if min > nums[i] { min = nums[i]; } if max < nums[i] { max = nums[i]; } } // 设置需要的桶的数量 let bucket_num = (max - mi...
index += 1; } } nums } pub fn quick_sort(mut nums: Vec<i32>) -> Vec<i32> { if nums.is_empty() { return nums; } let n = nums.len() - 1; quick_sort_internally(&mut nums, 0, n); nums } fn quick_sort_internally(nums: &mut Vec<i32>, start: usize, end: usize) { if start >= e...
nums[index as usize] = num;
random_line_split
main.rs
// Configure jemalloc as the `global_allocator` when configured. This is // so that we use the sized deallocation apis jemalloc provides // (namely `sdallocx`). // // The symbol overrides documented below are also performed so that we can // ensure that we use a consistent allocator across the rustc <-> llvm boundary #...
() { // Pull in jemalloc when enabled. // // Note that we're pulling in a static copy of jemalloc which means that to // pull it in we need to actually reference its symbols for it to get // linked. The two crates we link to here, std and rustc_driver, are both // dynamic libraries. That means t...
main
identifier_name
main.rs
// Configure jemalloc as the `global_allocator` when configured. This is // so that we use the sized deallocation apis jemalloc provides // (namely `sdallocx`). // // The symbol overrides documented below are also performed so that we can // ensure that we use a consistent allocator across the rustc <-> llvm boundary #...
#[used] static _F4: unsafe extern "C" fn(usize) -> *mut c_void = jemalloc_sys::malloc; #[used] static _F5: unsafe extern "C" fn(*mut c_void, usize) -> *mut c_void = jemalloc_sys::realloc; #[used] static _F6: unsafe extern "C" fn(*mut c_void) = jemalloc_sys::free; ...
{ // Pull in jemalloc when enabled. // // Note that we're pulling in a static copy of jemalloc which means that to // pull it in we need to actually reference its symbols for it to get // linked. The two crates we link to here, std and rustc_driver, are both // dynamic libraries. That means to p...
identifier_body
main.rs
// Configure jemalloc as the `global_allocator` when configured. This is // so that we use the sized deallocation apis jemalloc provides // (namely `sdallocx`). //
// The symbol overrides documented below are also performed so that we can // ensure that we use a consistent allocator across the rustc <-> llvm boundary #[cfg(feature = "jemalloc")] #[global_allocator] static ALLOC: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc; #[cfg(feature = "tikv-jemalloc-sys")] use ...
random_line_split
name_pool.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::cast; use std::libc::c_char; pub struct NamePool { strbufs: ~[~[u8]] } pub fn NamePool() -> @mut Na...
impl NamePool { pub fn add(&mut self, s: ~str) -> *c_char { unsafe { let mut strbuf = ~[]; for i in range(0, s.len()) { strbuf.push(s[i]); } strbuf.push(0); self.strbufs.push(strbuf); return cast::transmute(&self.strb...
{ @mut NamePool { strbufs: ~[] } }
identifier_body
name_pool.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::cast; use std::libc::c_char; pub struct NamePool { strbufs: ~[~[u8]]
pub fn NamePool() -> @mut NamePool { @mut NamePool { strbufs: ~[] } } impl NamePool { pub fn add(&mut self, s: ~str) -> *c_char { unsafe { let mut strbuf = ~[]; for i in range(0, s.len()) { strbuf.push(s[i]); } strbuf.push(0); ...
}
random_line_split
name_pool.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::cast; use std::libc::c_char; pub struct NamePool { strbufs: ~[~[u8]] } pub fn NamePool() -> @mut Na...
(&mut self, s: ~str) -> *c_char { unsafe { let mut strbuf = ~[]; for i in range(0, s.len()) { strbuf.push(s[i]); } strbuf.push(0); self.strbufs.push(strbuf); return cast::transmute(&self.strbufs[self.strbufs.len() - 1][0]);...
add
identifier_name
run.rs
// Copyright 2017, 2019 Guanhao Yin <sopium@mysterious.site> // This file is part of TiTun. // TiTun is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) ...
else { notify .unwrap() .notify(0) .context("failed to notify grand parent")?; } } // So rustc does not warn about unused. #[cfg(not(unix))] let _notify = notify; } scope0.cancelled().await; ...
{ super::systemd::notify_ready() .unwrap_or_else(|e| warn!("failed to notify systemd: {:#}", e)); }
conditional_block
run.rs
// Copyright 2017, 2019 Guanhao Yin <sopium@mysterious.site> // This file is part of TiTun. // TiTun is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) ...
use tokio::signal::unix::{signal, SignalKind}; let mut term = signal(SignalKind::terminate()).unwrap(); term.recv().await; info!("Received SIGTERM, shutting down."); }); let dev_name = c.interface.name.clone().unwrap(); let tun = AsyncTun::open(&dev_name).context("failed t...
{ #[cfg(unix)] let mut c = c; let scope0 = AsyncScope::new(); scope0.spawn_canceller(async move { tokio::signal::ctrl_c() .await .unwrap_or_else(|e| warn!("ctrl_c failed: {:#}", e)); info!("Received SIGINT or Ctrl-C, shutting down."); }); if let Some(sto...
identifier_body
run.rs
// Copyright 2017, 2019 Guanhao Yin <sopium@mysterious.site> // This file is part of TiTun. // TiTun is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) ...
( config_file_path: Option<std::path::PathBuf>, weak: std::sync::Weak<WgState>, ) -> anyhow::Result<()> { use tokio::signal::unix::{signal, SignalKind}; let mut hangups = signal(SignalKind::hangup())?; while hangups.recv().await.is_some() { if let Some(ref config_file_path) = config_file_pat...
reload_on_sighup
identifier_name
run.rs
// Copyright 2017, 2019 Guanhao Yin <sopium@mysterious.site> // This file is part of TiTun. // TiTun is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) ...
.await .unwrap_or_else(|e| warn!("ctrl_c failed: {:#}", e)); info!("Received SIGINT or Ctrl-C, shutting down."); }); if let Some(stop_rx) = stop_rx { scope0.spawn_canceller(async move { stop_rx.await.unwrap(); }); } #[cfg(unix)] scope0.spaw...
let scope0 = AsyncScope::new(); scope0.spawn_canceller(async move { tokio::signal::ctrl_c()
random_line_split
incremental.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::fmt; use std::sync::Arc; use style::ComputedValues; bitflags! { #[doc = "Individual layout actions t...
(self) -> RestyleDamage { self & Reflow } /// Elements of self which should also get set on any child flows. pub fn propagate_down(self) -> RestyleDamage { self & BubbleISizes } } impl fmt::Show for RestyleDamage { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::FormatErro...
propagate_up
identifier_name
incremental.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::fmt; use std::sync::Arc; use style::ComputedValues; bitflags! { #[doc = "Individual layout actions t...
if self.contains(damage) { if!first_elem { try!(write!(f, " | ")); } try!(write!(f, "{}", damage_str)); first_elem = false; } } if first_elem { try!(write!(f, "NoDamage")); } Ok(()) } } // NB: We n...
random_line_split
incremental.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::fmt; use std::sync::Arc; use style::ComputedValues; bitflags! { #[doc = "Individual layout actions t...
} if first_elem { try!(write!(f, "NoDamage")); } Ok(()) } } // NB: We need the braces inside the RHS due to Rust #8012. This particular // version of this macro might be safe anyway, but we want to avoid silent // breakage on modifications. macro_rules! add_if_not_eq...
{ if !first_elem { try!(write!(f, " | ")); } try!(write!(f, "{}", damage_str)); first_elem = false; }
conditional_block
incremental.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::fmt; use std::sync::Arc; use style::ComputedValues; bitflags! { #[doc = "Individual layout actions t...
Ok(()) } } // NB: We need the braces inside the RHS due to Rust #8012. This particular // version of this macro might be safe anyway, but we want to avoid silent // breakage on modifications. macro_rules! add_if_not_equal( ($old:ident, $new:ident, $damage:ident, [ $($effect:ident),* ], [ $($sty...
{ let mut first_elem = true; let to_iter = [ (Repaint, "Repaint") , (BubbleISizes, "BubbleISizes") , (Reflow, "Reflow") ]; for &(damage, damage_str) in to_iter.iter() { if self.contains(damage) { if !first_e...
identifier_body
mod.rs
//! This module provides the interface to different solvers. //! //! Both [`coin_cbc`](https://docs.rs/coin_cbc/latest/coin_cbc/) and //! [`minilp`](https://docs.rs/minilp/0.2.2/minilp/) are available as cargo //! [features](https://doc.rust-lang.org/cargo/reference/features.html). To use //! them, specify your depende...
None => None } }) } fn eval_with(&self, index: &LpExprArenaIndex, values: &HashMap<String, f32>) -> f32 { match self.related_problem.unwrap().obj_expr_arena.as_ref().unwrap().expr_ref_at(*index) { LpExprNode::LpCompExpr(operation, left, right) ...
Some(obj_expr_arena) => Some( self.eval_with(&obj_expr_arena.get_root_index(), &self.results) ),
random_line_split
mod.rs
//! This module provides the interface to different solvers. //! //! Both [`coin_cbc`](https://docs.rs/coin_cbc/latest/coin_cbc/) and //! [`minilp`](https://docs.rs/minilp/0.2.2/minilp/) are available as cargo //! [features](https://doc.rust-lang.org/cargo/reference/features.html). To use //! them, specify your depende...
pub fn with_problem(status: Status, results: HashMap<String, f32>, problem: &LpProblem) -> Solution { Solution { status, results, related_problem: Some(problem) } } fn check_possible_solution(&self) { match &self.status { Status::Unbou...
{ Solution { status, results, related_problem: None } }
identifier_body
mod.rs
//! This module provides the interface to different solvers. //! //! Both [`coin_cbc`](https://docs.rs/coin_cbc/latest/coin_cbc/) and //! [`minilp`](https://docs.rs/minilp/0.2.2/minilp/) are available as cargo //! [features](https://doc.rust-lang.org/cargo/reference/features.html). To use //! them, specify your depende...
<'a>(status: Status, results: HashMap<String, f32>) -> Solution<'a> { Solution { status, results, related_problem: None } } pub fn with_problem(status: Status, results: HashMap<String, f32>, problem: &LpProblem) -> Solution { Solution { sta...
new
identifier_name
x86stdcall2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
assert!(res != 0u8); } #[cfg(not(windows))] pub fn main() { }
random_line_split
x86stdcall2.rs
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let heap = unsafe { kernel32::GetProcessHeap() }; let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) }; assert!(mem!= 0u); let res = unsafe { kernel32::HeapFree(heap, 0u32, mem) }; assert!(res!= 0u8); } #[cfg(not(windows))] pub fn main() { }
main
identifier_name
x86stdcall2.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 ...
#[cfg(not(windows))] pub fn main() { }
{ let heap = unsafe { kernel32::GetProcessHeap() }; let mem = unsafe { kernel32::HeapAlloc(heap, 0u32, 100u32) }; assert!(mem != 0u); let res = unsafe { kernel32::HeapFree(heap, 0u32, mem) }; assert!(res != 0u8); }
identifier_body
inlining-issue67557-ice.rs
// This used to cause an ICE for an internal index out of range due to simd_shuffle_indices being // passed the wrong Instance, causing issues with inlining. See #67557. // // run-pass // compile-flags: -Zmir-opt-level=4 #![feature(platform_intrinsics, repr_simd)] extern "platform-intrinsic" { fn simd_shuffle2<T, ...
#[derive(Debug, PartialEq)] struct Simd2(u8, u8); fn main() { unsafe { let _: Simd2 = inline_me(); } } #[inline(always)] unsafe fn inline_me() -> Simd2 { const IDX: [u32; 2] = [0, 3]; simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) }
random_line_split
inlining-issue67557-ice.rs
// This used to cause an ICE for an internal index out of range due to simd_shuffle_indices being // passed the wrong Instance, causing issues with inlining. See #67557. // // run-pass // compile-flags: -Zmir-opt-level=4 #![feature(platform_intrinsics, repr_simd)] extern "platform-intrinsic" { fn simd_shuffle2<T, ...
{ const IDX: [u32; 2] = [0, 3]; simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) }
identifier_body
inlining-issue67557-ice.rs
// This used to cause an ICE for an internal index out of range due to simd_shuffle_indices being // passed the wrong Instance, causing issues with inlining. See #67557. // // run-pass // compile-flags: -Zmir-opt-level=4 #![feature(platform_intrinsics, repr_simd)] extern "platform-intrinsic" { fn simd_shuffle2<T, ...
() { unsafe { let _: Simd2 = inline_me(); } } #[inline(always)] unsafe fn inline_me() -> Simd2 { const IDX: [u32; 2] = [0, 3]; simd_shuffle2(Simd2(10, 11), Simd2(12, 13), IDX) }
main
identifier_name
error.rs
use std::error::Error; use std::fmt::{Display, Formatter}; use std::fmt::Result as FmtResult; use fmt::Format; pub type CliResult<T> = Result<T, CliError>; #[derive(Debug)] #[allow(dead_code)] pub enum CliError { Generic(String), UnknownExt(String), Unknown } // Copies clog::error::Error; impl CliError ...
<'a>(&'a self) -> &'a str { match *self { CliError::Generic(ref d) => &*d, CliError::UnknownExt(ref d) => &*d, CliError::Unknown => "An unknown fatal error has occurred, please consider filing a bug-report!" } } fn cause(&self) -> Option<&Error> ...
description
identifier_name
error.rs
use std::error::Error; use std::fmt::{Display, Formatter}; use std::fmt::Result as FmtResult; use fmt::Format; pub type CliResult<T> = Result<T, CliError>; #[derive(Debug)] #[allow(dead_code)] pub enum CliError { Generic(String), UnknownExt(String), Unknown } // Copies clog::error::Error; impl CliError ...
fn cause(&self) -> Option<&Error> { match *self { CliError::Generic(..) => None, CliError::UnknownExt(..) => None, CliError::Unknown => None, } } }
{ match *self { CliError::Generic(ref d) => &*d, CliError::UnknownExt(ref d) => &*d, CliError::Unknown => "An unknown fatal error has occurred, please consider filing a bug-report!" } }
identifier_body
error.rs
use std::error::Error; use std::fmt::{Display, Formatter}; use std::fmt::Result as FmtResult; use fmt::Format; pub type CliResult<T> = Result<T, CliError>; #[derive(Debug)] #[allow(dead_code)] pub enum CliError { Generic(String), UnknownExt(String), Unknown } // Copies clog::error::Error; impl CliError ...
::std::process::exit(0) } } } impl Display for CliError { fn fmt(&self, f: &mut Formatter) -> FmtResult { write!(f, "{} {}", Format::Error("error:"), self.description()) } } impl Error for CliError { fn description<'a>(&'a self) -> &'a str { match *self { ...
} else { println!("{}", self);
random_line_split
no-redundancy.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 ...
} // @has no_redundancy/struct.Outer.html // @has - '//*[@id="synthetic-implementations-list"]/*[@class="impl"]//*/code' "impl<T> Send for \ // Outer<T> where T: Copy + Send" pub struct Outer<T> { inner_field: Inner<T>, }
unsafe impl<T> Send for Inner<T> where T: Copy + Send, {
random_line_split
no-redundancy.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 ...
<T> { inner_field: Inner<T>, }
Outer
identifier_name
macos.rs
use std::{io, path, ptr, mem, ffi, slice, time}; use libc::{c_void, c_int, c_schar, c_uchar, size_t, uid_t, sysctl, sysctlnametomib, timeval, statfs}; use data::*; use super::common::*; use super::unix; pub struct PlatformImpl; macro_rules! sysctl_mib { ($len:expr, $name:expr) => { { let mut m...
let mounts = unsafe { slice::from_raw_parts(mptr, len as usize) }; Ok(mounts.iter().map(statfs_to_fs).collect::<Vec<_>>()) } fn block_device_statistics(&self) -> io::Result<BTreeMap<String, BlockDeviceStats>> { Err(io::Error::new(io::ErrorKind::Other, "Not supported")) } fn ne...
{ return Err(io::Error::new(io::ErrorKind::Other, "getmntinfo() failed")) }
conditional_block
macos.rs
use std::{io, path, ptr, mem, ffi, slice, time}; use libc::{c_void, c_int, c_schar, c_uchar, size_t, uid_t, sysctl, sysctlnametomib, timeval, statfs}; use data::*; use super::common::*; use super::unix; pub struct PlatformImpl; macro_rules! sysctl_mib { ($len:expr, $name:expr) => { { let mut m...
#[link(name = "c")] extern "C" { #[link_name = "getmntinfo$INODE64"] fn getmntinfo(mntbufp: *mut *mut statfs, flags: c_int) -> c_int; }
{ Filesystem { files: (x.f_files as usize).saturating_sub(x.f_ffree as usize), files_total: x.f_files as usize, files_avail: x.f_ffree as usize, free: ByteSize::b(x.f_bfree * x.f_bsize as u64), avail: ByteSize::b(x.f_bavail * x.f_bsize as u64), total: ByteSize::b(x.f_...
identifier_body
macos.rs
use std::{io, path, ptr, mem, ffi, slice, time}; use libc::{c_void, c_int, c_schar, c_uchar, size_t, uid_t, sysctl, sysctlnametomib, timeval, statfs}; use data::*; use super::common::*; use super::unix; pub struct PlatformImpl; macro_rules! sysctl_mib { ($len:expr, $name:expr) => { { let mut m...
fn battery_life(&self) -> io::Result<BatteryLife> { Err(io::Error::new(io::ErrorKind::Other, "Not supported")) } fn on_ac_power(&self) -> io::Result<bool> { Err(io::Error::new(io::ErrorKind::Other, "Not supported")) } fn mounts(&self) -> io::Result<Vec<Filesystem>> { let m...
let mut data: timeval = unsafe { mem::zeroed() }; sysctl!(KERN_BOOTTIME, &mut data, mem::size_of::<timeval>()); Ok(DateTime::<Utc>::from_utc(NaiveDateTime::from_timestamp(data.tv_sec.into(), data.tv_usec as u32), Utc)) }
random_line_split
macos.rs
use std::{io, path, ptr, mem, ffi, slice, time}; use libc::{c_void, c_int, c_schar, c_uchar, size_t, uid_t, sysctl, sysctlnametomib, timeval, statfs}; use data::*; use super::common::*; use super::unix; pub struct
; macro_rules! sysctl_mib { ($len:expr, $name:expr) => { { let mut mib: [c_int; $len] = [0; $len]; let mut sz: size_t = mib.len(); let s = ffi::CString::new($name).unwrap(); unsafe { sysctlnametomib(s.as_ptr(), &mut mib[0], &mut sz) }; mib ...
PlatformImpl
identifier_name
move_error.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 struct MoveError { move_from: mc::cmt, move_to: Option<MoveSpanAndPath> } impl MoveError { pub fn with_move_info(move_from: mc::cmt, move_to: Option<MoveSpanAndPath>) -> MoveError { MoveError { move_from: move_from, mo...
pub fn report_potential_errors(&self, bccx: &BorrowckCtxt) { report_move_errors(bccx, self.errors.borrow().deref()) } }
random_line_split
move_error.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 ...
(errors: &Vec<MoveError>) -> Vec<GroupedMoveErrors> { let mut grouped_errors = Vec::new(); for error in errors.iter() { append_to_grouped_errors(&mut grouped_errors, error) } return grouped_errors; fn append_to_grouped_errors(grouped_errors: &mut Vec<Grouped...
group_errors_with_same_origin
identifier_name
lib.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 future::BoxFuture; use futures::{future, FutureExt, TryFutureExt}; use iml_postgres::{ alert, sqlx::{self, PgPool}, }; use iml_service_queue::service_queue...
#[test] fn test_client_eviction_parser() { let inputs = vec![ " LustreError: 0:0:(ldlm_lockd.c:356:waiting_locks_callback()) ### lock callback timer expired after 101s: evicting client at 0@lo ns: mdt-ffff8801cd5be000 lock: ffff880126f8f480/0xe99a593b682aed45 lrc: 3/0,0 mode: PR/PR res: 85...
{ let x = " Lustre: 2689:0:(genops.c:1379:obd_export_evict_by_uuid()) lustre-OST0001: evicting 26959b68-1208-1fca-1f07-da2dc872c55f at adminstrative request"; assert_debug_snapshot!(admin_client_eviction_parser(x).unwrap()); }
identifier_body
lib.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 future::BoxFuture; use futures::{future, FutureExt, TryFutureExt}; use iml_postgres::{ alert, sqlx::{self, PgPool}, }; use iml_service_queue::service_queue...
.boxed() } fn client_connection_handler<'a>( pool: &'a PgPool, msg: &str, host_id: i32, host_content_type_id: i32, ) -> HandlerFut<'a> { if let Some((lustre_pid, msg)) = client_connection_parser(msg) { return alert::raise( pool, AlertRecordType::ClientConnectEvent...
None, AlertSeverity::ERROR, host_id, ) .err_into()
random_line_split
lib.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 future::BoxFuture; use futures::{future, FutureExt, TryFutureExt}; use iml_postgres::{ alert, sqlx::{self, PgPool}, }; use iml_service_queue::service_queue...
(msg: &str) -> Option<(i32, String)> { lazy_static! { static ref TARGET_END: Regex = Regex::new(r":\s+connection from").unwrap(); } // get the client NID out of the string let nid_start = msg.find('@')? + 1; let nid_len = msg[nid_start..].find(' ')?; // and the UUID let uuid_start =...
client_connection_parser
identifier_name
dom.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/. */ //! Types and traits used to access the DOM from style calculation. #![allow(unsafe_code)] use context::SharedSt...
<ConcreteNode> where ConcreteNode: TNode { stack: Vec<ConcreteNode>, } impl<ConcreteNode> TreeIterator<ConcreteNode> where ConcreteNode: TNode { fn new(root: ConcreteNode) -> TreeIterator<ConcreteNode> { let mut stack = vec![]; stack.push(root); TreeIterator { stack: stack, ...
TreeIterator
identifier_name
dom.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/. */ //! Types and traits used to access the DOM from style calculation. #![allow(unsafe_code)] use context::SharedSt...
} impl<ConcreteNode> Iterator for TreeIterator<ConcreteNode> where ConcreteNode: TNode { type Item = ConcreteNode; fn next(&mut self) -> Option<ConcreteNode> { let ret = self.stack.pop(); ret.map(|node| self.stack.extend(node.rev_children())); ret } } p...
{ self.stack.pop() }
identifier_body
dom.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/. */ //! Types and traits used to access the DOM from style calculation. #![allow(unsafe_code)] use context::SharedSt...
fn is_dirty(&self) -> bool; unsafe fn set_dirty(&self, value: bool); fn has_dirty_descendants(&self) -> bool; unsafe fn set_dirty_descendants(&self, value: bool); fn needs_dirty_on_viewport_size_changed(&self) -> bool; unsafe fn set_dirty_on_viewport_size_changed(&self); fn can_be_frag...
fn has_changed(&self) -> bool; unsafe fn set_changed(&self, value: bool);
random_line_split
compiler.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015-2020 Matthias Beyer <mail@beyermatthias.de> and contributors // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the F...
(acc: Accuracy, dt: NaiveDateTime, modname: &str, matchstr: &str) { let compiler = DatePathCompiler::new(acc, Format::default()); let res = compiler.compile(modname, &dt); assert!(res.is_ok()); let res = res.unwrap(); let s = res.to_str(); assert!(s.is_ok()); ...
test_accuracy
identifier_name