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
hidecm.rs
extern crate usbg; use std::path::PathBuf;
use usbg::UsbGadget; use usbg::UsbGadgetState; use usbg::UsbGadgetFunction; use usbg::UsbGadgetConfig; use usbg::hid; use usbg::ecm; fn main() { // general setup let mut g1 = UsbGadget::new("g1", 0x1d6b, // Linux Foundation 0x0104, // Multifuncti...
use std::fs;
random_line_split
traits-negative-impls.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 ...
struct TestType; impl!Send for TestType {} is_send(TestType); //~^ ERROR `dummy1b::TestType` cannot be sent between threads safely } fn dummy1c() { struct TestType; impl!Send for TestType {} is_send((8, TestType)); //~^ ERROR `dummy1c::TestType` cannot be sent between threads safely }...
//~| ERROR `dummy::TestType` cannot be sent between threads safely } fn dummy1b() {
random_line_split
traits-negative-impls.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 ...
() { struct TestType; impl!Send for TestType {} // This will complain about a missing Send impl because `Sync` is implement *just* // for T that are `Send`. Look at #20366 and #19950 is_sync(Outer2(TestType)); //~^ ERROR `main::TestType` cannot be sent between threads safely }
main
identifier_name
recent_chooser_dialog.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 Bin; use Buildable; use Container;
use Window; use ffi; use glib::translate::*; use glib_ffi; use gobject_ffi; use std::mem; use std::ptr; glib_wrapper! { pub struct RecentChooserDialog(Object<ffi::GtkRecentChooserDialog, ffi::GtkRecentChooserDialogClass>): Dialog, Window, Bin, Container, Widget, Buildable, RecentChooser; match fn { ge...
use Dialog; use RecentChooser; use Widget;
random_line_split
race_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub cons...
} impl flatbuffers::Push for Race { type Output = Race; #[inline] fn push(&self, dst: &mut [u8], _rest: &[u8]) { unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); } } } impl flatbuffers::EndianScalar for Race { #[inline] fn to_little_endian(self) -> Self { let b = i8::to_le(sel...
{ let b = unsafe { flatbuffers::read_scalar_at::<i8>(buf, loc) }; Self(b) }
identifier_body
race_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub cons...
(pub i8); #[allow(non_upper_case_globals)] impl Race { pub const None: Self = Self(-1); pub const Human: Self = Self(0); pub const Dwarf: Self = Self(1); pub const Elf: Self = Self(2); pub const ENUM_MIN: i8 = -1; pub const ENUM_MAX: i8 = 2; pub const ENUM_VALUES: &'static [Self] = &[ Self::None, ...
Race
identifier_name
race_generated.rs
// automatically generated by the FlatBuffers compiler, do not modify extern crate flatbuffers; use std::mem; use std::cmp::Ordering; use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub cons...
pub const ENUM_VALUES_RACE: [Race; 4] = [ Race::None, Race::Human, Race::Dwarf, Race::Elf, ]; #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct Race(pub i8); #[allow(non_upper_case_globals)] impl Race { pub const None: Self = Self(-1); pub const Human: Se...
pub const ENUM_MAX_RACE: i8 = 2; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] #[allow(non_camel_case_types)]
random_line_split
rect.rs
use crate::{fragment::Bounds, util, Cell, Point}; use std::fmt; use ncollide2d::shape::{Segment, Shape}; use sauron::{ html::{attributes, attributes::*}, svg::{attributes::*, *}, Node, }; use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct Rect { pub start: Point, pub end: Point, pub is...
pub(in crate) fn rounded_new( start: Point, end: Point, is_filled: bool, radius: f32, is_broken: bool, ) -> Self { let mut rect = Rect { start, end, is_filled, radius: Some(radius), is_broken, }...
{ let mut rect = Rect { start, end, is_filled, radius: None, is_broken, }; rect.sort_reorder_end_points(); rect }
identifier_body
rect.rs
use crate::{fragment::Bounds, util, Cell, Point}; use std::fmt; use ncollide2d::shape::{Segment, Shape}; use sauron::{ html::{attributes, attributes::*}, svg::{attributes::*, *}, Node, }; use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct Rect { pub start: Point, pub end: Point, pub is...
} /// recompute the rect with start and end point offset by the cell /// location pub(in crate) fn absolute_position(&self, cell: Cell) -> Self { Rect { start: cell.absolute_position(self.start), end: cell.absolute_position(self.end), ..*self } } ...
{ let tmp_start = self.start; self.start = self.end; self.end = tmp_start; }
conditional_block
rect.rs
use crate::{fragment::Bounds, util, Cell, Point}; use std::fmt; use ncollide2d::shape::{Segment, Shape}; use sauron::{ html::{attributes, attributes::*}, svg::{attributes::*, *}, Node, }; use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct Rect { pub start: Point, pub end: Point, pub is...
} } pub(in crate) fn scale(&self, scale: f32) -> Self { Rect { start: self.start.scale(scale), end: self.end.scale(scale), radius: self.radius.map(|r| r * scale), ..*self } } pub(crate) fn width(&self) -> f32 { self.end.x -...
pub(in crate) fn absolute_position(&self, cell: Cell) -> Self { Rect { start: cell.absolute_position(self.start), end: cell.absolute_position(self.end), ..*self
random_line_split
rect.rs
use crate::{fragment::Bounds, util, Cell, Point}; use std::fmt; use ncollide2d::shape::{Segment, Shape}; use sauron::{ html::{attributes, attributes::*}, svg::{attributes::*, *}, Node, }; use std::cmp::Ordering; #[derive(Debug, Clone)] pub struct Rect { pub start: Point, pub end: Point, pub is...
(start: Point, end: Point, is_filled: bool, is_broken: bool) -> Self { let mut rect = Rect { start, end, is_filled, radius: None, is_broken, }; rect.sort_reorder_end_points(); rect } pub(in crate) fn rounded_new( ...
new
identifier_name
add_helpers.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Field, Ident, Index}; pub fn tuple_exprs(fields: &[&Field], method_ident: &Ident) -> Vec<TokenStream> { let mut exprs = vec![]; for i in 0..fields.len() { let i = Index::from(i); // generates `self.0.add(rhs.0)` let expr = quote...
exprs }
exprs.push(expr) }
random_line_split
add_helpers.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Field, Ident, Index}; pub fn tuple_exprs(fields: &[&Field], method_ident: &Ident) -> Vec<TokenStream> { let mut exprs = vec![]; for i in 0..fields.len() { let i = Index::from(i); // generates `self.0.add(rhs.0)` let expr = quote...
{ let mut exprs = vec![]; for field in fields { // It's safe to unwrap because struct fields always have an identifier let field_id = field.ident.as_ref().unwrap(); // generates `x: self.x.add(rhs.x)` let expr = quote!(self.#field_id.#method_ident(rhs.#field_id)); exprs....
identifier_body
add_helpers.rs
use proc_macro2::TokenStream; use quote::quote; use syn::{Field, Ident, Index}; pub fn tuple_exprs(fields: &[&Field], method_ident: &Ident) -> Vec<TokenStream> { let mut exprs = vec![]; for i in 0..fields.len() { let i = Index::from(i); // generates `self.0.add(rhs.0)` let expr = quote...
(fields: &[&Field], method_ident: &Ident) -> Vec<TokenStream> { let mut exprs = vec![]; for field in fields { // It's safe to unwrap because struct fields always have an identifier let field_id = field.ident.as_ref().unwrap(); // generates `x: self.x.add(rhs.x)` let expr = quote...
struct_exprs
identifier_name
mod.rs
// // imag - the personal information management suite for the commandline // Copyright (C) 2015, 2016 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 ...
// You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA // pub mod editor; pub mod plain; pub mod stdout;
// This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. //
random_line_split
mutex.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 ...
} #[inline] pub unsafe fn try_lock(&self) -> bool { ffi::TryEnterCriticalSection(self.inner.get())!= 0 } pub unsafe fn unlock(&self) { ffi::LeaveCriticalSection(self.inner.get()); } pub unsafe fn destroy(&self) { ffi::DeleteCriticalSection(self.inner.get()); } ...
pub unsafe fn lock(&self) { ffi::EnterCriticalSection(self.inner.get());
random_line_split
mutex.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 ...
(&self) { ffi::AcquireSRWLockExclusive(self.inner.get()) } #[inline] pub unsafe fn try_lock(&self) -> bool { ffi::TryAcquireSRWLockExclusive(self.inner.get())!= 0 } #[inline] pub unsafe fn unlock(&self) { ffi::ReleaseSRWLockExclusive(self.inner.get()) } #[inline] ...
lock
identifier_name
mutex.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 ...
#[inline] pub unsafe fn unlock(&self) { ffi::ReleaseSRWLockExclusive(self.inner.get()) } #[inline] pub unsafe fn destroy(&self) { //... } } pub struct ReentrantMutex { inner: Box<UnsafeCell<ffi::CRITICAL_SECTION>> } unsafe impl Send for ReentrantMutex {} unsafe impl Sync for R...
{ ffi::TryAcquireSRWLockExclusive(self.inner.get()) != 0 }
identifier_body
single_glyph.rs
extern crate freetype as ft; extern crate unicode_normalization; use unicode_normalization::UnicodeNormalization; const WIDTH: usize = 32; const HEIGHT: usize = 24; fn
(bitmap: ft::Bitmap, x: usize, y: usize) -> [[u8; WIDTH]; HEIGHT] { let mut figure = [[0; WIDTH]; HEIGHT]; let mut p = 0; let mut q = 0; let w = bitmap.width() as usize; let x_max = x + w; let y_max = y + bitmap.rows() as usize; for i in x.. x_max { for j in y.. y_max { ...
draw_bitmap
identifier_name
single_glyph.rs
extern crate freetype as ft; extern crate unicode_normalization; use unicode_normalization::UnicodeNormalization; const WIDTH: usize = 32; const HEIGHT: usize = 24; fn draw_bitmap(bitmap: ft::Bitmap, x: usize, y: usize) -> [[u8; WIDTH]; HEIGHT]
fn main() { let ref mut args = std::env::args(); if args.len()!= 3 { let exe = args.next().unwrap(); println!("Usage: {} font character", exe); return } let ref font = args.nth(1).unwrap(); let character = args.next().and_then(|s| s.nfc().next()).unwrap() as usize; le...
{ let mut figure = [[0; WIDTH]; HEIGHT]; let mut p = 0; let mut q = 0; let w = bitmap.width() as usize; let x_max = x + w; let y_max = y + bitmap.rows() as usize; for i in x .. x_max { for j in y .. y_max { if i < WIDTH && j < HEIGHT { figure[j][i] |= bit...
identifier_body
single_glyph.rs
extern crate freetype as ft; extern crate unicode_normalization; use unicode_normalization::UnicodeNormalization; const WIDTH: usize = 32; const HEIGHT: usize = 24; fn draw_bitmap(bitmap: ft::Bitmap, x: usize, y: usize) -> [[u8; WIDTH]; HEIGHT] { let mut figure = [[0; WIDTH]; HEIGHT]; let mut p = 0; let ...
for i in 0.. HEIGHT { for j in 0.. WIDTH { print!("{}", match figure[i][j] { p if p == 0 => " ", p if p < 128 => "*", _ => "+" } ); } println!(""); } }
let glyph = face.glyph(); let x = glyph.bitmap_left() as usize; let y = HEIGHT - glyph.bitmap_top() as usize; let figure = draw_bitmap(glyph.bitmap(), x, y);
random_line_split
single_glyph.rs
extern crate freetype as ft; extern crate unicode_normalization; use unicode_normalization::UnicodeNormalization; const WIDTH: usize = 32; const HEIGHT: usize = 24; fn draw_bitmap(bitmap: ft::Bitmap, x: usize, y: usize) -> [[u8; WIDTH]; HEIGHT] { let mut figure = [[0; WIDTH]; HEIGHT]; let mut p = 0; let ...
} q = 0; p += 1; } figure } fn main() { let ref mut args = std::env::args(); if args.len()!= 3 { let exe = args.next().unwrap(); println!("Usage: {} font character", exe); return } let ref font = args.nth(1).unwrap(); let character = args.n...
{ figure[j][i] |= bitmap.buffer()[q * w + p]; q += 1; }
conditional_block
process_builder.rs
use std::collections::HashMap; use std::ffi::CString; use std::fmt::{self, Formatter}; use std::io::process::{Command, ProcessOutput, InheritFd}; use std::os; use std::path::BytesContainer; use util::{CargoResult, ProcessError, process_error}; #[derive(Clone, PartialEq, Show)] pub struct ProcessBuilder { program:...
<T: BytesContainer>(mut self, arguments: &[T]) -> ProcessBuilder { self.args.extend(arguments.iter().map(|t| { CString::from_slice(t.container_as_bytes()) })); self } pub fn get_args(&self) -> &[CString] { self.args.as_slice() } pub fn cwd(mut self, path: Pa...
args
identifier_name
process_builder.rs
use std::collections::HashMap; use std::ffi::CString; use std::fmt::{self, Formatter}; use std::io::process::{Command, ProcessOutput, InheritFd}; use std::os; use std::path::BytesContainer; use util::{CargoResult, ProcessError, process_error}; #[derive(Clone, PartialEq, Show)] pub struct ProcessBuilder { program:...
pub fn args<T: BytesContainer>(mut self, arguments: &[T]) -> ProcessBuilder { self.args.extend(arguments.iter().map(|t| { CString::from_slice(t.container_as_bytes()) })); self } pub fn get_args(&self) -> &[CString] { self.args.as_slice() } pub fn cwd(m...
{ self.args.push(CString::from_slice(arg.container_as_bytes())); self }
identifier_body
process_builder.rs
use std::collections::HashMap; use std::ffi::CString; use std::fmt::{self, Formatter}; use std::io::process::{Command, ProcessOutput, InheritFd}; use std::os; use std::path::BytesContainer; use util::{CargoResult, ProcessError, process_error}; #[derive(Clone, PartialEq, Show)] pub struct ProcessBuilder { program:...
} program } } pub fn process<T: BytesContainer>(cmd: T) -> CargoResult<ProcessBuilder> { Ok(ProcessBuilder { program: CString::from_slice(cmd.container_as_bytes()), args: Vec::new(), cwd: try!(os::getcwd()), env: HashMap::new(), }) }
program.push(' '); program.push_str(&format!("{}", String::from_utf8_lossy(arg.as_bytes()))[]);
random_line_split
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: @mut CrateContext, fn_id: ast::def_id) -> ast::def_id { let _icx = push_ctxt("maybe_instantiate_inline"); match ccx.external.find(&fn_id) { Some(&Some(node_id)) => { // Already inline debug!("maybe_instantiate_inline(%s): already inline as node id %d", ...
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 ...
trans_item(ccx, item); local_def(my_id) } csearch::found_parent(_, _) => { ccx.sess.bug("maybe_get_item_ast returned a found_parent \ with a non-item parent"); } csearch::found(ast::ii_method(impl_did, is_provided, mth)) => { ccx.sta...
non-enum parent") }
random_line_split
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, ccx.maps, /*bad*/ copy c, d) }); return match csearch_result { csearch::not_found => { ccx.external.insert(fn_id, None); fn_id } cse...
{ let _icx = push_ctxt("maybe_instantiate_inline"); match ccx.external.find(&fn_id) { Some(&Some(node_id)) => { // Already inline debug!("maybe_instantiate_inline(%s): already inline as node id %d", ty::item_path_str(ccx.tcx, fn_id), node_id); retur...
identifier_body
schleifen.rs
fn main()
// for-Schleife for c in 1..6 { println!("for: {}", c); } // mit enumerate() können die Durchläufe gezählt werden (bei 0 geht es los!) for (d,e) in (10..16).enumerate() { println!("for mit enumerate: {}, Durchlauf: {}", e, d); } }
{ // Schleifen - loop, for, while // loop (ohne Abbruch -> Endlosschleife) // break - Abbruch der Schleife, continue - aktuellen Durchlauf abbrechen let mut a = 0; loop { a = a + 1; println!("loop: {}", a); if a == 5 { break } } // while (Sobald Bedingung erfül...
identifier_body
schleifen.rs
fn
() { // Schleifen - loop, for, while // loop (ohne Abbruch -> Endlosschleife) // break - Abbruch der Schleife, continue - aktuellen Durchlauf abbrechen let mut a = 0; loop { a = a + 1; println!("loop: {}", a); if a == 5 { break } } // while (Sobald Bedingung er...
main
identifier_name
schleifen.rs
fn main() { // Schleifen - loop, for, while // loop (ohne Abbruch -> Endlosschleife) // break - Abbruch der Schleife, continue - aktuellen Durchlauf abbrechen let mut a = 0; loop { a = a + 1; println!("loop: {}", a); if a == 5 { break } } // while (Sobald Bedin...
}
}
random_line_split
schleifen.rs
fn main() { // Schleifen - loop, for, while // loop (ohne Abbruch -> Endlosschleife) // break - Abbruch der Schleife, continue - aktuellen Durchlauf abbrechen let mut a = 0; loop { a = a + 1; println!("loop: {}", a); if a == 5
} // while (Sobald Bedingung erfüllt...) let mut b = 0; while b!= 5 { b += 1; println!("while: {}", b); } // for-Schleife for c in 1..6 { println!("for: {}", c); } // mit enumerate() können die Durchläufe gezählt werden (bei 0 geht es los!) for (d...
{ break }
conditional_block
resolver.rs
use std::sync::{Arc,Mutex}; use std::collections::HashMap; use std::io::BufReader; use rustls::{ResolvesServerCert, ClientHello}; use rustls::sign::{CertifiedKey, RSASigningKey}; use rustls::internal::pemfile; use sozu_command::proxy::{CertificateAndKey, CertFingerprint, AddCertificate, RemoveCertificate}; use sozu_co...
(&mut self, remove_certificate: RemoveCertificate) { if let Some(_data) = self.certificates.get(&remove_certificate.fingerprint) { //let cert = &data.cert.cert[0]; if remove_certificate.names.is_empty() { //FIXME: waiting for https://github.com/briansmith/webpki/pull/65 to merge to get the DNS n...
remove_certificate
identifier_name
resolver.rs
use std::sync::{Arc,Mutex}; use std::collections::HashMap; use std::io::BufReader; use rustls::{ResolvesServerCert, ClientHello}; use rustls::sign::{CertifiedKey, RSASigningKey}; use rustls::internal::pemfile; use sozu_command::proxy::{CertificateAndKey, CertFingerprint, AddCertificate, RemoveCertificate}; use sozu_co...
} error!("could not look up a certificate for server name '{}'", name); None } } pub fn generate_certified_key(certificate_and_key: CertificateAndKey) -> Option<CertifiedKey> { let mut chain = Vec::new(); let mut cert_reader = BufReader::new(certificate_and_key.certificate.as_bytes()); let parse...
{ trace!("looking for certificate for {:?} with fingerprint {:?}", name, kv.1); return resolver.certificates.get(&kv.1).as_ref().map(|data| data.cert.clone()); }
conditional_block
resolver.rs
use std::sync::{Arc,Mutex}; use std::collections::HashMap; use std::io::BufReader; use rustls::{ResolvesServerCert, ClientHello}; use rustls::sign::{CertifiedKey, RSASigningKey}; use rustls::internal::pemfile; use sozu_command::proxy::{CertificateAndKey, CertFingerprint, AddCertificate, RemoveCertificate}; use sozu_co...
self.certificates.insert(fingerprint.clone(), data); for name in names.drain(..) { self.domains.domain_insert(name.into_bytes(), fingerprint.clone()); } Some(fingerprint) } else { None } } pub fn remove_certificate(&mut self, remove_certificate: RemoveCertificate) { ...
cert: certified_key, }; let fingerprint = CertFingerprint(fingerprint);
random_line_split
resolver.rs
use std::sync::{Arc,Mutex}; use std::collections::HashMap; use std::io::BufReader; use rustls::{ResolvesServerCert, ClientHello}; use rustls::sign::{CertifiedKey, RSASigningKey}; use rustls::internal::pemfile; use sozu_command::proxy::{CertificateAndKey, CertFingerprint, AddCertificate, RemoveCertificate}; use sozu_co...
} self.certificates.remove(&remove_certificate.fingerprint); } } pub struct CertificateResolverWrapper(pub Mutex<CertificateResolver>); impl CertificateResolverWrapper { pub fn new() -> CertificateResolverWrapper { CertificateResolverWrapper(Mutex::new(CertificateResolver::new())) } pub fn add_...
{ if let Some(_data) = self.certificates.get(&remove_certificate.fingerprint) { //let cert = &data.cert.cert[0]; if remove_certificate.names.is_empty() { //FIXME: waiting for https://github.com/briansmith/webpki/pull/65 to merge to get the DNS names // create a untrusted::Input /...
identifier_body
footer.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{generated::css_classes::C, Msg}; use chrono::{offset::Local, Datelike}; use iml_wire_types::{Branding, Conf}; use seed::{prelude::*, *}; pub fn view(conf:...
"© 2020 - DDN EXAScaler ".to_string() } } }; let footer_text = match conf.branding { Branding::Whamcloud => div![ footer_string, year.to_string(), " DDN. All rights reserved.".to_string(), ], _ => div![footer_string...
} else {
random_line_split
footer.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{generated::css_classes::C, Msg}; use chrono::{offset::Local, Datelike}; use iml_wire_types::{Branding, Conf}; use seed::{prelude::*, *}; pub fn view(conf:...
year.to_string(), " DDN. All rights reserved.".to_string(), ], _ => div![footer_string], }; footer![ class![C.h_5, C.flex, C.justify_center], div![class![C.px_5, C.text_sm, C.items_center,], footer_text] ] }
{ let year = Local::now().year(); let footer_string = match conf.branding { Branding::Whamcloud => format!( "Integrated Manager for Lustre software {} is Copyright © ", conf.version ), _ => { if let Some(version) = &conf.exa_version { ...
identifier_body
footer.rs
// Copyright (c) 2020 DDN. All rights reserved. // Use of this source code is governed by a MIT-style // license that can be found in the LICENSE file. use crate::{generated::css_classes::C, Msg}; use chrono::{offset::Local, Datelike}; use iml_wire_types::{Branding, Conf}; use seed::{prelude::*, *}; pub fn
(conf: &Conf) -> impl View<Msg> { let year = Local::now().year(); let footer_string = match conf.branding { Branding::Whamcloud => format!( "Integrated Manager for Lustre software {} is Copyright © ", conf.version ), _ => { if let Some(version) = &con...
view
identifier_name
compositor_thread.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/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
(&self, f: &mut Formatter) -> Result<(), Error> { match *self { Msg::Exit => write!(f, "Exit"), Msg::ShutdownComplete => write!(f, "ShutdownComplete"), Msg::ChangeRunningAnimationsState(..) => write!(f, "ChangeRunningAnimationsState"), Msg::SetFrameTree(..) => wri...
fmt
identifier_name
compositor_thread.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/. */ //! Communication with the compositor thread. use SendableFrameTree; use compositor::CompositingReason; use eucli...
} } /// Sends messages to the compositor. pub struct CompositorProxy { pub sender: Sender<Msg>, pub event_loop_waker: Box<EventLoopWaker>, } impl CompositorProxy { pub fn send(&self, msg: Msg) { // Send a message and kick the OS event loop awake. if let Err(err) = self.sender.send(msg)...
random_line_split
minmax-stability-issue-23687.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. #![feature(iter_min_max, cmp_partial, iter_cmp)] use std::fmt::Debug; use std::cmp::{self, PartialOrd, Ordering}; #[derive(Debug, Copy, Clone, PartialEq...
// 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
random_line_split
minmax-stability-issue-23687.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 ...
} impl Ord for Foo { fn cmp(&self, other: &Foo) -> Ordering { self.n.cmp(&other.n) } } fn main() { let a = Foo { n: 4, name: "a" }; let b = Foo { n: 4, name: "b" }; let c = Foo { n: 8, name: "c" }; let d = Foo { n: 8, name: "d" }; let e = Foo { n: 22, name: "e" }; let f = Foo ...
{ Some(self.cmp(other)) }
identifier_body
minmax-stability-issue-23687.rs
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
() { let a = Foo { n: 4, name: "a" }; let b = Foo { n: 4, name: "b" }; let c = Foo { n: 8, name: "c" }; let d = Foo { n: 8, name: "d" }; let e = Foo { n: 22, name: "e" }; let f = Foo { n: 22, name: "f" }; let data = [a, b, c, d, e, f]; // `min` should return the left when the values ar...
main
identifier_name
modadd.rs
use num::{Zero, BigUint, BigInt, Integer, PrimInt}; /// The `ModAdd` trait defines an interface for calculating the sum of two integers /// modulo a modulus. pub trait ModAdd { /// The function `mod_add` computes the sum /// ```text /// x + y (mod m) /// ``` /// where x, y, and m are integers, an...
}
{ let x = BigInt::from(735172765); let y = BigInt::from(446253906); let modulus = BigInt::from(0); x.mod_add(&y, &modulus); }
identifier_body
modadd.rs
use num::{Zero, BigUint, BigInt, Integer, PrimInt}; /// The `ModAdd` trait defines an interface for calculating the sum of two integers /// modulo a modulus. pub trait ModAdd { /// The function `mod_add` computes the sum /// ```text /// x + y (mod m) /// ``` /// where x, y, and m are integers, an...
TestCase { x: BigInt::from(464283712), y: BigInt::from(559073817), modulus: BigInt::from(635717262), sum: BigInt::from(387640267), }, TestCase { x: BigInt::from(-812470905)...
data: vec! [
random_line_split
modadd.rs
use num::{Zero, BigUint, BigInt, Integer, PrimInt}; /// The `ModAdd` trait defines an interface for calculating the sum of two integers /// modulo a modulus. pub trait ModAdd { /// The function `mod_add` computes the sum /// ```text /// x + y (mod m) /// ``` /// where x, y, and m are integers, an...
{ data: Vec<TestCase>, } fn mod_add_test_cases() -> Test { Test { data: vec! [ TestCase { x: BigInt::from(464283712), y: BigInt::from(559073817), modulus: BigInt::from(635717262), sum: B...
Test
identifier_name
range.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
pub fn new(low: X, high: X) -> Range<X> { assert!(low < high, "Range::new called with `low >= high`"); SampleRange::construct_range(low, high) } } impl<Sup: SampleRange> Sample<Sup> for Range<Sup> { #[inline] fn sample<R: Rng>(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) } } im...
/// `[low, high)`. Panics if `low >= high`.
random_line_split
range.rs
// Copyright 2013 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or ...
(low: X, high: X) -> Range<X> { assert!(low < high, "Range::new called with `low >= high`"); SampleRange::construct_range(low, high) } } impl<Sup: SampleRange> Sample<Sup> for Range<Sup> { #[inline] fn sample<R: Rng>(&mut self, rng: &mut R) -> Sup { self.ind_sample(rng) } } impl<Sup: Sample...
new
identifier_name
serviceworkerglobalscope.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 devtools; use devtools_traits::DevtoolScriptControlMsg; use dom::abstractworker::WorkerScriptMsg; use dom::bin...
impl ServiceWorkerGlobalScope { fn new_inherited(init: WorkerGlobalScopeInit, worker_url: ServoUrl, from_devtools_receiver: Receiver<DevtoolScriptControlMsg>, runtime: Runtime, own_sender: Sender<ServiceWorkerScriptMsg>, ...
scope_url: ServoUrl, }
random_line_split
serviceworkerglobalscope.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 devtools; use devtools_traits::DevtoolScriptControlMsg; use dom::abstractworker::WorkerScriptMsg; use dom::bin...
fn clone(&self) -> Box<ScriptChan + Send> { box ServiceWorkerChan { sender: self.sender.clone(), } } } #[dom_struct] pub struct ServiceWorkerGlobalScope { workerglobalscope: WorkerGlobalScope, #[ignore_heap_size_of = "Defined in std"] receiver: Receiver<ServiceWorkerSc...
{ self.sender .send(ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(msg))) .map_err(|_| ()) }
identifier_body
serviceworkerglobalscope.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 devtools; use devtools_traits::DevtoolScriptControlMsg; use dom::abstractworker::WorkerScriptMsg; use dom::bin...
(&self, msg: CommonScriptMsg) { self.handle_script_event(ServiceWorkerScriptMsg::CommonWorker(WorkerScriptMsg::Common(msg))); } pub fn script_chan(&self) -> Box<ScriptChan + Send> { box ServiceWorkerChan { sender: self.own_sender.clone() } } fn dispatch_activate(&se...
process_event
identifier_name
mod.rs
/// Chapter 4.23 - Closures /// [Chapter 4.23] https://doc.rust-lang.org/book/closures.html pub use self::closures::*; pub mod closures { pub fn main() { println!("====\nClosure:\n"); // We did not need to annotate the // types of arguments the closure // takes or the values it retu...
}
{ let mut num = 5; // `num` will be changed { let mut add_num = |x: i32| num += x; add_num(5); } assert_eq!(10, num); // For move closure let mut num = 5; { // Move -> copied `num` value // We took ownership...
identifier_body
mod.rs
/// Chapter 4.23 - Closures /// [Chapter 4.23] https://doc.rust-lang.org/book/closures.html pub use self::closures::*; pub mod closures { pub fn main() { println!("====\nClosure:\n"); // We did not need to annotate the // types of arguments the closure // takes or the values it retu...
res += 1; res }; println!("Assert check: {}", 4 == plus_two(2)); println!("Assert check: {}", simelar_closures()); // The environment for a closure can include bindings // from its enclosing // It borrows the binding! // we took ownership...
let mut res: i32 = x; res += 1;
random_line_split
mod.rs
/// Chapter 4.23 - Closures /// [Chapter 4.23] https://doc.rust-lang.org/book/closures.html pub use self::closures::*; pub mod closures { pub fn main() { println!("====\nClosure:\n"); // We did not need to annotate the // types of arguments the closure // takes or the values it retu...
(x: i32) -> i32 { x + 1 } let plus_one_v2 = |x: i32| -> i32 { x + 1 }; let plus_one_v3 = |x: i32| x + 1 ; plus_one_v1(10) == plus_one_v2(10) && plus_one_v2(10) == plus_one_v3(10) } fn move_closures() { let mut num = 5; // `num` will be changed ...
plus_one_v1
identifier_name
update_common.rs
use rmpv::Value; use utils::serialize; use request_type_key::RequestTypeKey; use code::Code; use common_operation::CommonOperation; use FIX_STR_PREFIX; use action::Action; use rmpv::decode::read_value; #[derive(Debug)] pub struct UpdateCommon { pub space: u64, pub index: u64, pub operation_type: CommonOper...
}
{ (RequestTypeKey::Update, serialize(Value::Map(vec![(Value::from(Code::SpaceId as u8), Value::from(self.space)), (Value::from(Code::IndexId as u8), Value::from(self.index)), (Value::from(Code::Key as u8), ...
identifier_body
update_common.rs
use rmpv::Value; use utils::serialize; use request_type_key::RequestTypeKey; use code::Code; use common_operation::CommonOperation; use FIX_STR_PREFIX; use action::Action; use rmpv::decode::read_value; #[derive(Debug)] pub struct
{ pub space: u64, pub index: u64, pub operation_type: CommonOperation, pub field_number: u8, pub argument: Value, pub keys: Vec<Value>, } impl Action for UpdateCommon { fn get(&self) -> (RequestTypeKey, Vec<u8>) { (RequestTypeKey::Update, serialize(Value::Map(vec![(Value::...
UpdateCommon
identifier_name
update_common.rs
use rmpv::Value; use utils::serialize; use request_type_key::RequestTypeKey; use code::Code; use common_operation::CommonOperation; use FIX_STR_PREFIX; use action::Action; use rmpv::decode::read_value; #[derive(Debug)] pub struct UpdateCommon { pub space: u64, pub index: u64, pub operation_type: CommonOper...
pub field_number: u8, pub argument: Value, pub keys: Vec<Value>, } impl Action for UpdateCommon { fn get(&self) -> (RequestTypeKey, Vec<u8>) { (RequestTypeKey::Update, serialize(Value::Map(vec![(Value::from(Code::SpaceId as u8), Value::from(self.space)), ...
random_line_split
scoping_rules_borrowing_aliasing.rs
struct Point { x: i32, y: i32, z: i32 } pub fn main() { let mut point = Point { x: 0, y: 0, z: 0 }; { let borrowed_point = &point; let another_borrow = &point; // Data can be accessed via the references and the original owner println!("Point has coordinates: ({}, {}, {})", ...
// Change data via mutable reference mutable_borrow.x = 5; mutable_borrow.y = 2; mutable_borrow.z = 1; // Error! Can't borrow `point` as immutable because it's currently // borrowed as mutable. //let mutable_borrow = &point; // Error! Can't borrow `point...
} { let mutable_borrow = &mut point;
random_line_split
scoping_rules_borrowing_aliasing.rs
struct
{ x: i32, y: i32, z: i32 } pub fn main() { let mut point = Point { x: 0, y: 0, z: 0 }; { let borrowed_point = &point; let another_borrow = &point; // Data can be accessed via the references and the original owner println!("Point has coordinates: ({}, {}, {})", ...
Point
identifier_name
subscriber.rs
// Copyright (C) 2015 <Rick Richardson r@12sidedtech.com> // // This software may be modified and distributed under the terms // of the MIT license. See the LICENSE file for details. use std::fmt::Display; use reactive::{Subscriber}; use sendable::Sendable; pub struct StdoutSubscriber<A> where A : Display { inde...
Decoupler { index: None, data_tx: tx, } } } impl<Q, I> Subscriber for Decoupler<Q, I> where I : Send, Q : Sendable<Item=I> { type Input = I; fn on_next(&mut self, t: I) -> bool { //TODO better handle queue failure, maybe put the returned buf //...
pub fn new(tx: Q) -> Decoupler<Q,I> {
random_line_split
subscriber.rs
// Copyright (C) 2015 <Rick Richardson r@12sidedtech.com> // // This software may be modified and distributed under the terms // of the MIT license. See the LICENSE file for details. use std::fmt::Display; use reactive::{Subscriber}; use sendable::Sendable; pub struct StdoutSubscriber<A> where A : Display { inde...
} pub struct Decoupler<Q, I> where I : Send, Q : Sendable { index: Option<usize>, data_tx: Q, } impl<Q, I> Decoupler<Q, I> where I : Send, Q : Sendable { pub fn new(tx: Q) -> Decoupler<Q,I> { Decoupler { index: None, data_tx: tx, } } } impl<Q, I> Subscriber f...
{ println!("{}", t); true }
identifier_body
subscriber.rs
// Copyright (C) 2015 <Rick Richardson r@12sidedtech.com> // // This software may be modified and distributed under the terms // of the MIT license. See the LICENSE file for details. use std::fmt::Display; use reactive::{Subscriber}; use sendable::Sendable; pub struct StdoutSubscriber<A> where A : Display { inde...
(v : &'a mut Box<Vec<I>>) -> Collect<'a, I> { Collect { index: None, val: v } } } impl<'a, I> Subscriber for Collect<'a, I> where I : 'a { type Input = I; fn on_next(&mut self, t: I) -> bool { self.val.push(t); true } }
new
identifier_name
issue_234.rs
use zip::result::ZipError; const BUF: &[u8] = &[ 0, 80, 75, 1, 2, 127, 120, 0, 3, 3, 75, 80, 232, 3, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 7, 0, 0, 0, 0, 65, 0, 1, 0, 0, 0, 4, 0, 0, 224, 255, 0, 255, 255, 255, 255, 255, 255, 20, 39, 221, 221, 221, 221, 221, 221, 205, 221, 221, 221, 42, 221, 221, 221, 221, 221, 221...
() { let reader = std::io::Cursor::new(&BUF); let archive = zip::ZipArchive::new(reader); match archive { Err(ZipError::InvalidArchive(_)) => {} value => panic!("Unexpected value: {:?}", value), } }
invalid_header
identifier_name
issue_234.rs
use zip::result::ZipError; const BUF: &[u8] = &[ 0, 80, 75, 1, 2, 127, 120, 0, 3, 3, 75, 80, 232, 3, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 7, 0, 0, 0, 0, 65, 0, 1, 0, 0, 0, 4, 0, 0, 224, 255, 0, 255, 255, 255, 255, 255, 255, 20, 39, 221, 221, 221, 221, 221, 221, 205, 221, 221, 221, 42, 221, 221, 221, 221, 221, 221...
120, 0, 99, 99, 99, 99, 99, 99, 94, 7, 0, 0, 0, 0, 0, 0, 213, 213, 213, 213, 213, 213, 213, 213, 213, 7, 0, 0, 211, 211, 211, 211, 124, 236, 99, 99, 99, 94, 7, 0, 0, 0, 0, 0, 0, 213, 213, 213, 213, 213, 213, 213, 213, 213, 7, 0, 0, 211, 211, 211, 211, 124, 236, 234, 0, 0, 0, 3, 8, 0, 0, 0, 12, 0, 0, 0, ...
random_line_split
issue_234.rs
use zip::result::ZipError; const BUF: &[u8] = &[ 0, 80, 75, 1, 2, 127, 120, 0, 3, 3, 75, 80, 232, 3, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 7, 0, 0, 0, 0, 65, 0, 1, 0, 0, 0, 4, 0, 0, 224, 255, 0, 255, 255, 255, 255, 255, 255, 20, 39, 221, 221, 221, 221, 221, 221, 205, 221, 221, 221, 42, 221, 221, 221, 221, 221, 221...
value => panic!("Unexpected value: {:?}", value), } }
{}
conditional_block
issue_234.rs
use zip::result::ZipError; const BUF: &[u8] = &[ 0, 80, 75, 1, 2, 127, 120, 0, 3, 3, 75, 80, 232, 3, 0, 0, 0, 0, 0, 0, 3, 0, 1, 0, 7, 0, 0, 0, 0, 65, 0, 1, 0, 0, 0, 4, 0, 0, 224, 255, 0, 255, 255, 255, 255, 255, 255, 20, 39, 221, 221, 221, 221, 221, 221, 205, 221, 221, 221, 42, 221, 221, 221, 221, 221, 221...
{ let reader = std::io::Cursor::new(&BUF); let archive = zip::ZipArchive::new(reader); match archive { Err(ZipError::InvalidArchive(_)) => {} value => panic!("Unexpected value: {:?}", value), } }
identifier_body
adt-tuple-struct.rs
// Unit test for the "user substitutions" that are annotated on each // node. struct SomeStruct<T>(T); fn no_annot() { let c = 66; SomeStruct(&c); } fn annot_underscore() { let c = 66; SomeStruct::<_>(&c); } fn annot_reference_any_lifetime() { let c = 66; SomeStruct::<&u32>(&c); } fn annot_...
}; } fn main() { }
random_line_split
adt-tuple-struct.rs
// Unit test for the "user substitutions" that are annotated on each // node. struct SomeStruct<T>(T); fn no_annot() { let c = 66; SomeStruct(&c); } fn annot_underscore() { let c = 66; SomeStruct::<_>(&c); } fn annot_reference_any_lifetime() { let c = 66; SomeStruct::<&u32>(&c); } fn annot_...
<'a>(c: &'a u32) { SomeStruct::<&'a u32>(c); } fn annot_reference_named_lifetime_in_closure<'a>(_: &'a u32) { let _closure = || { let c = 66; SomeStruct::<&'a u32>(&c); //~ ERROR }; } fn annot_reference_named_lifetime_in_closure_ok<'a>(c: &'a u32) { let _closure = || { SomeStru...
annot_reference_named_lifetime_ok
identifier_name
adt-tuple-struct.rs
// Unit test for the "user substitutions" that are annotated on each // node. struct SomeStruct<T>(T); fn no_annot() { let c = 66; SomeStruct(&c); } fn annot_underscore() { let c = 66; SomeStruct::<_>(&c); } fn annot_reference_any_lifetime() { let c = 66; SomeStruct::<&u32>(&c); } fn annot_...
fn main() { }
{ let _closure = || { SomeStruct::<&'a u32>(c); }; }
identifier_body
iterator_utils.rs
pub(crate) struct CartesianProductIterator<'a, I1, I2> { v1: &'a [I1], v2: &'a [I2], v1_idx: usize, v2_idx: usize } impl <'a, I1, I2> CartesianProductIterator<'a, I1, I2> { pub fn new(v1: &'a [I1], v2: &'a [I2]) -> Self { CartesianProductIterator { v1, v2, v1_idx: 0, v2_idx: 0 } } } impl <'a, I1: 'a,...
else { self.v2_idx += 1; Some((self.v1.get(self.v1_idx).unwrap(), self.v2.get(self.v2_idx - 1).unwrap())) } } } #[cfg(test)] mod tests { use expectest::prelude::*; use super::CartesianProductIterator; #[test] fn cartesian_product_iterator_empty_array_tests() { expect!(CartesianProductIt...
{ self.v2_idx = 1; self.v1_idx += 1; if self.v1_idx == self.v1.len() { None } else { Some((self.v1.get(self.v1_idx).unwrap(), self.v2.get(self.v2_idx - 1).unwrap())) } }
conditional_block
iterator_utils.rs
pub(crate) struct CartesianProductIterator<'a, I1, I2> { v1: &'a [I1], v2: &'a [I2], v1_idx: usize, v2_idx: usize } impl <'a, I1, I2> CartesianProductIterator<'a, I1, I2> { pub fn new(v1: &'a [I1], v2: &'a [I2]) -> Self { CartesianProductIterator { v1, v2, v1_idx: 0, v2_idx: 0 } } } impl <'a, I1: 'a, ...
expect!(i1.next()).to(be_some().value((&1, &2))); expect!(i1.next()).to(be_none()); let vec3 = vec![1, 2]; let mut i2 = CartesianProductIterator::new(&vec3, &vec2); expect!(i2.next()).to(be_some().value((&1, &2))); expect!(i2.next()).to(be_some().value((&2, &2))); expect!(i2.next()).to(be_n...
fn cartesian_product_iterator_tests() { let vec1 = vec![1]; let vec2 = vec![2]; let mut i1 = CartesianProductIterator::new(&vec1, &vec2);
random_line_split
iterator_utils.rs
pub(crate) struct CartesianProductIterator<'a, I1, I2> { v1: &'a [I1], v2: &'a [I2], v1_idx: usize, v2_idx: usize } impl <'a, I1, I2> CartesianProductIterator<'a, I1, I2> { pub fn new(v1: &'a [I1], v2: &'a [I2]) -> Self { CartesianProductIterator { v1, v2, v1_idx: 0, v2_idx: 0 } } } impl <'a, I1: 'a,...
(&mut self) -> Option<Self::Item> { if self.v1.is_empty() || self.v2.is_empty() || self.v1_idx == self.v1.len() && self.v2_idx == self.v2.len() { None } else if self.v2_idx == self.v2.len() { self.v2_idx = 1; self.v1_idx += 1; if self.v1_idx == self.v1.len() { None } ...
next
identifier_name
font.rs
use std::fmt; use crossfont::Size as FontSize; use serde::de::{self, Visitor}; use serde::{Deserialize, Deserializer}; use alacritty_config_derive::ConfigDeserialize; use crate::config::ui_config::Delta; /// Font config. /// /// Defaults are provided at the level of this struct per platform, but not per /// field i...
Font { size: Size(size),..self } } #[inline] pub fn size(&self) -> FontSize { self.size.0 } /// Get normal font description. pub fn normal(&self) -> &FontDescription { &self.normal } /// Get bold font description. pub fn bold(&self) -> FontDescription { ...
pub fn with_size(self, size: FontSize) -> Font {
random_line_split
font.rs
use std::fmt; use crossfont::Size as FontSize; use serde::de::{self, Visitor}; use serde::{Deserialize, Deserializer}; use alacritty_config_derive::ConfigDeserialize; use crate::config::ui_config::Delta; /// Font config. /// /// Defaults are provided at the level of this struct per platform, but not per /// field i...
} impl<'de> Deserialize<'de> for Size { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { struct NumVisitor; impl<'v> Visitor<'v> for NumVisitor { type Value = Size; fn expecting(&self, f: &mut fmt::Formatter<'_>) ->...
{ Self(FontSize::new(11.)) }
identifier_body
font.rs
use std::fmt; use crossfont::Size as FontSize; use serde::de::{self, Visitor}; use serde::{Deserialize, Deserializer}; use alacritty_config_derive::ConfigDeserialize; use crate::config::ui_config::Delta; /// Font config. /// /// Defaults are provided at the level of this struct per platform, but not per /// field i...
<E: de::Error>(self, value: f64) -> Result<Self::Value, E> { Ok(Size(FontSize::new(value as f32))) } fn visit_u64<E: de::Error>(self, value: u64) -> Result<Self::Value, E> { Ok(Size(FontSize::new(value as f32))) } } deserializer.deser...
visit_f64
identifier_name
util.rs
use std::ffi::{CString, CStr}; use std::str; use libc::{c_char, c_int}; use err::HdfsErr; use native::*; use dfs::HdfsFs; pub fn str_to_chars(s: &str) -> *const c_char { CString::new(s.as_bytes()).unwrap().as_ptr() } pub fn chars_to_str<'a>(chars: *const c_char) -> &'a str { let slice = unsafe { CStr::from_ptr(c...
else { 0 } } /// Hdfs Utility pub struct HdfsUtil; /// HDFS Utility impl HdfsUtil { /// Copy file from one filesystem to another. /// /// #### Params /// * ```srcFS``` - The handle to source filesystem. /// * ```src``` - The path of source file. /// * ```dstFS``` - The handle to destination filesystem. ...
{ 1 }
conditional_block
util.rs
use std::ffi::{CString, CStr}; use std::str; use libc::{c_char, c_int}; use err::HdfsErr; use native::*; use dfs::HdfsFs; pub fn str_to_chars(s: &str) -> *const c_char { CString::new(s.as_bytes()).unwrap().as_ptr() } pub fn chars_to_str<'a>(chars: *const c_char) -> &'a str { let slice = unsafe { CStr::from_ptr(c...
(src_fs: &HdfsFs, src: &str, dst_fs: &HdfsFs, dst: &str) -> Result<bool, HdfsErr> { let res = unsafe { hdfsMove(src_fs.raw(), str_to_chars(src), dst_fs.raw(), str_to_chars(dst)) }; if res == 0 { Ok(true) } else { Err(HdfsErr::Unknown) } } }
mv
identifier_name
util.rs
use std::ffi::{CString, CStr}; use std::str; use libc::{c_char, c_int}; use err::HdfsErr; use native::*; use dfs::HdfsFs;
pub fn str_to_chars(s: &str) -> *const c_char { CString::new(s.as_bytes()).unwrap().as_ptr() } pub fn chars_to_str<'a>(chars: *const c_char) -> &'a str { let slice = unsafe { CStr::from_ptr(chars) }.to_bytes(); str::from_utf8(slice).unwrap() } pub fn bool_to_c_int(val: bool) -> c_int { if val { 1 } else { 0 }...
random_line_split
util.rs
use std::ffi::{CString, CStr}; use std::str; use libc::{c_char, c_int}; use err::HdfsErr; use native::*; use dfs::HdfsFs; pub fn str_to_chars(s: &str) -> *const c_char
pub fn chars_to_str<'a>(chars: *const c_char) -> &'a str { let slice = unsafe { CStr::from_ptr(chars) }.to_bytes(); str::from_utf8(slice).unwrap() } pub fn bool_to_c_int(val: bool) -> c_int { if val { 1 } else { 0 } } /// Hdfs Utility pub struct HdfsUtil; /// HDFS Utility impl HdfsUtil { /// Copy file fro...
{ CString::new(s.as_bytes()).unwrap().as_ptr() }
identifier_body
alias_ok.rs
extern crate crucible; use std::cell::Cell; use std::mem; use crucible::*; use crucible::method_spec::{MethodSpec, MethodSpecBuilder, clobber_globals}; fn f(x: &Cell<u8>, y: &Cell<u8>) { x.swap(y); } #[crux_test] fn f_test() { clobber_globals(); let x = Cell::new(u8::symbolic("x")); let y = Cell::new(...
msb.gather_assumes(); // Call happens here crucible_assert!(y.get() > 0); msb.set_return(&()); msb.gather_asserts(); msb.finish() } #[crux_test] fn use_f() { f_spec().enable(); let a = Cell::new(u8::symbolic("a")); let b = Cell::new(u8::symbolic("b")); crucible_assume!(0 < a....
msb.add_arg(& &y);
random_line_split
alias_ok.rs
extern crate crucible; use std::cell::Cell; use std::mem; use crucible::*; use crucible::method_spec::{MethodSpec, MethodSpecBuilder, clobber_globals}; fn f(x: &Cell<u8>, y: &Cell<u8>) { x.swap(y); } #[crux_test] fn f_test() { clobber_globals(); let x = Cell::new(u8::symbolic("x")); let y = Cell::new(...
{ f_spec().enable(); let a = Cell::new(u8::symbolic("a")); let b = Cell::new(u8::symbolic("b")); crucible_assume!(0 < a.get() && a.get() < 10); crucible_assume!(b.get() == 0); f(&a, &b); crucible_assert!(0 < b.get()); crucible_assert!(b.get() < 10); }
identifier_body
alias_ok.rs
extern crate crucible; use std::cell::Cell; use std::mem; use crucible::*; use crucible::method_spec::{MethodSpec, MethodSpecBuilder, clobber_globals}; fn
(x: &Cell<u8>, y: &Cell<u8>) { x.swap(y); } #[crux_test] fn f_test() { clobber_globals(); let x = Cell::new(u8::symbolic("x")); let y = Cell::new(u8::symbolic("y")); crucible_assume!(x.get() > 0); f(&x, &y); crucible_assert!(y.get() > 0); } fn f_spec() -> MethodSpec { let x = Cell::new...
f
identifier_name
util.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...
Some(1), ]) .data(); assert_eq!(data, indexed.data()); } }
{ let value_data = Int32Array::from((0..10).collect::<Vec<i32>>()).data(); let value_offsets = Buffer::from(&[0, 2, 5, 10].to_byte_slice()); let list_data_type = DataType::List(Box::new(DataType::Int32)); let list_data = ArrayData::builder(list_data_type.clone()) .len(3) ...
identifier_body
util.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...
() { let value_data = Int32Array::from((0..10).collect::<Vec<i32>>()).data(); let value_offsets = Buffer::from(&[0, 2, 5, 10].to_byte_slice()); let list_data_type = DataType::List(Box::new(DataType::Int32)); let list_data = ArrayData::builder(list_data_type.clone()) .len(3) ...
test_take_value_index_from_list
identifier_name
util.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...
} } (UInt32Array::from(values), new_offsets) } #[cfg(test)] mod tests { use super::*; use std::sync::Arc; use crate::array::ArrayData; use crate::datatypes::{DataType, ToByteSlice}; #[test] fn test_apply_bin_op_to_option_bitmap() { assert_eq!( Ok(None), ...
} } else { new_offsets.push(current_offset);
random_line_split
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use std::fmt; /// The real `ToCss...
} impl ToCss for Au { fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write { write!(dest, "{}px", self.to_f64_px()) } } macro_rules! impl_to_css_for_predefined_type { ($name: ty) => { impl<'a> ToCss for $name { fn to_css<W>(&self, dest: &mut W) -> fmt::Result w...
{ let mut iter = self.iter(); iter.next().unwrap().to_css(dest)?; for item in iter { dest.write_str(", ")?; item.to_css(dest)?; } Ok(()) }
identifier_body
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use std::fmt; /// The real `ToCss...
(&self, value: f32) -> bool { match *self { AllowedNumericType::All => true, AllowedNumericType::NonNegative => value >= 0., } } /// Clamp the value following the rules of this numeric type. #[inline] pub fn clamp(&self, val: Au) -...
is_ok
identifier_name
values.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/. */ //! Helper types and traits for the handling of CSS values. use app_units::Au; use std::fmt; /// The real `ToCss...
} } } impl ToCss for $name { fn to_css<W>(&self, dest: &mut W) -> ::std::fmt::Result where W: ::std::fmt::Write { match *self { $( $name::$variant => dest.write_str($css) ),+ } ...
pub fn parse(input: &mut ::cssparser::Parser) -> Result<$name, ()> { match_ignore_ascii_case! { try!(input.expect_ident()), $( $css => Ok($name::$variant), )+ _ => Err(())
random_line_split
union.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2...
(cx: &ExtCtxt, n: Spanned<u64>) -> P<ast::Expr> { cx.expr_lit(n.span, ast::LitInt(n.node as u64, ast::UnsignedIntLit(ast::TyUs))) } /// Returns the type of the field representing the given register /// within a `RegGroup` struct fn reg_struct_type(cx: &ExtCtxt, path: &Vec<String>, reg: &node::Reg) ...
expr_usize
identifier_name
union.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2...
}, ) }, } } /// Build the type associated with a register group fn build_union_type(&self, path: &Vec<String>, reg: &node::Reg, regs: &Vec<node::Reg>) -> Vec<P<ast::Item>> { let name = utils::path_ident(self.cx, path); // Registers are already sorted by ...
{ match reg_or_pad { RegOrPadding::Reg(reg) => self.build_reg_union_field(path, reg), RegOrPadding::Pad(length) => { let u8_path = self.cx.path_ident( DUMMY_SP, self.cx.ident_of("u8")); let u8_ty: P<ast::Ty> = self.cx.ty_path(u8_path); let ty: P<ast::Ty> = ...
identifier_body
union.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2...
} } } /// Build types for `RegUnions` pub struct BuildUnionTypes<'a> { builder: &'a mut Builder, cx: &'a ExtCtxt<'a> } impl<'a> BuildUnionTypes<'a> { pub fn new(builder: &'a mut Builder, cx: &'a ExtCtxt<'a>) -> BuildUnionTypes<'a> { BuildUnionTypes { builder: builder, cx: cx } } } fn expr_us...
{ self.index += 1; self.last_offset += reg.size(); Some(RegOrPadding::Reg(reg)) }
conditional_block
union.rs
// Zinc, the bare metal stack for rust. // Copyright 2014 Ben Gamari <bgamari@gmail.com> // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2...
self.cx.ident_of(reg.name.node.as_str()), ast::Public), id: ast::DUMMY_NODE_ID, ty: reg_struct_type(self.cx, &field_path, reg), attrs: attrs, } ) } /// Build field for padding or a register // Dummy spans allowed here because u8 doesn't come from anywhere #...
kind: ast::NamedField(
random_line_split
tests_v1kpdb.rs
use chrono::{Timelike, Local, TimeZone, Datelike}; use kpdb::v1kpdb::V1Kpdb; use kpdb::v1error::V1KpdbError; #[test] fn test_new() { // No keyfile and password should give error as result let mut result = V1Kpdb::new("test/test_password.kdb".to_string(), None, None); match result { Ok(_) => asser...
let parent = new_group.parent.as_mut().unwrap(); assert_eq!(parent.borrow().id, 0); assert_eq!(db.header.num_groups, num_groups_before + 1); } #[test] fn test_create_group_w_everything() { let mut result = V1Kpdb::new("test/test_parsing.kdb".to_string(), Some("test".t...
(23, 59, 59)); assert_eq!(new_group.image, 0);
random_line_split
tests_v1kpdb.rs
use chrono::{Timelike, Local, TimeZone, Datelike}; use kpdb::v1kpdb::V1Kpdb; use kpdb::v1error::V1KpdbError; #[test] fn test_new() { // No keyfile and password should give error as result let mut result = V1Kpdb::new("test/test_password.kdb".to_string(), None, None); match result { Ok(_) => asser...
() { let mut result = V1Kpdb::new("test/test_parsing.kdb".to_string(), Some("test".to_string()), None); match result { Ok(ref mut e) => assert_eq!(e.load().is_ok(), true), Err(_) => assert!(false), }; let mut db = result.unwrap(); let num_groups_bef...
test_create_group_w_everything
identifier_name
tests_v1kpdb.rs
use chrono::{Timelike, Local, TimeZone, Datelike}; use kpdb::v1kpdb::V1Kpdb; use kpdb::v1error::V1KpdbError; #[test] fn test_new()
match db.load() { Ok(_) => assert!(false), Err(e) => assert_eq!(e, V1KpdbError::HashErr), }; } #[test] fn test_create_group_w_title_only() { let mut result = V1Kpdb::new("test/test_password.kdb".to_string(), Some("test".to_string()), None); match resul...
{ // No keyfile and password should give error as result let mut result = V1Kpdb::new("test/test_password.kdb".to_string(), None, None); match result { Ok(_) => assert!(false), Err(e) => assert_eq!(e, V1KpdbError::PassErr), }; // Test load at all and parameters result = V1Kpdb:...
identifier_body
subst.rs
pub fn erased(t: VecPerParamSpace<Ty<'tcx>>) -> Substs<'tcx> { Substs { types: t, regions: ErasedRegions } } pub fn empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: NonerasedRegions(VecPerParamSpace::empty()), } } p...
{ Substs::new(VecPerParamSpace::new(t, vec!(s), Vec::new()), VecPerParamSpace::new(r, Vec::new(), Vec::new())) }
identifier_body
subst.rs
pub fn trans_empty() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions_is_noop = match self.regions { ErasedRegions => false, // may be used to canonicalize ...
} }
random_line_split
subst.rs
() -> Substs<'tcx> { Substs { types: VecPerParamSpace::empty(), regions: ErasedRegions } } pub fn is_noop(&self) -> bool { let regions_is_noop = match self.regions { ErasedRegions => false, // may be used to canonicalize NonerasedRegions(r...
(&mut self) { self.region_binders_passed += 1; } fn exit_region_binder(&mut self) { self.region_binders_passed -= 1; } fn fold_region(&mut self, r: ty::Region) -> ty::Region { // Note: This routine only handles regions that are bound on // type declarations and other ou...
enter_region_binder
identifier_name
shutdown.rs
extern crate arg_parser; extern crate extra; extern crate syscall; use std::env; use std::io::{stderr, stdout, Error, Write}; use std::process::exit; use arg_parser::ArgParser; use extra::option::OptionalExt; use syscall::flag::{SIGTERM, SIGKILL}; const MAN_PAGE: &'static str = /* @MANSTART{shutdown} */ r#" NAME ...
}
{ syscall::kill(1, SIGKILL).map_err(|err| Error::from_raw_os_error(err.errno)).try(&mut stderr); }
conditional_block